Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5993729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:42:58+00:00 2026-05-22T23:42:58+00:00

Recently a question was posed regarding some Python code attempting to facilitate distributed computing

  • 0

Recently a question was posed regarding some Python code attempting to facilitate distributed computing through the use of pickled processes. Apparently, that functionality has historically been possible, but for security reasons the same functionality is disabled. On the second attempted at transmitting a function object through a socket, only the reference was transmitted. Correct me if I am wrong, but I do not believe this issue is related to Python’s late binding. Given the presumption that process and thread objects can not be pickled, is there any way to transmit a callable object? We would like to avoid transmitting compressed source code for each job, as that would probably make the entire attempt pointless. Only the Python core library can be used for portability reasons.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:42:59+00:00Added an answer on May 22, 2026 at 11:42 pm

    You could marshal the bytecode and pickle the other function things:

    import marshal
    import pickle
    
    marshaled_bytecode = marshal.dumps(your_function.func_code)
    # In this process, other function things are lost, so they have to be sent separated.
    pickled_name = pickle.dumps(your_function.func_name)
    pickled_arguments = pickle.dumps(your_function.func_defaults)
    pickled_closure = pickle.dumps(your_function.func_closure)
    # Send the marshaled bytecode and the other function things through a socket (they are byte strings).
    send_through_a_socket((marshaled_bytecode, pickled_name, pickled_arguments, pickled_closure))
    

    In another python program:

    import marshal
    import pickle
    import types
    
    # Receive the marshaled bytecode and the other function things.
    marshaled_bytecode, pickled_name, pickled_arguments, pickled_closure = receive_from_a_socket()
    your_function = types.FunctionType(marshal.loads(marshaled_bytecode), globals(), pickle.loads(pickled_name), pickle.loads(pickled_arguments), pickle.loads(pickled_closure))
    

    And any references to globals inside the function would have to be recreated in the script that receives the function.

    In Python 3, the function attributes used are __code__, __name__, __defaults__ and __closure__.

    Please do note that send_through_a_socket and receive_from_a_socket do not actually exist, and you should replace them by actual code that transmits data through sockets.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I posed a question , asking why some of my javascript code was
I recently asked a question and posted some code, to which a suggestion was
I recently posted a question which was answered by Bryan Watts, regarding generic repository
There was a post on here recently which posed the following question: You have
Relatively new to python. I recently posted a question in regards to validating that
Recently posted a question regarding the HttpClient over Https ( found here ). I've
Ok, so I posted a question recently regarding an error when adding a ManyToManyField
I recently asked a question regarding how to Save a list with nested elements
Until recently, I posted Python code (whitespace matters) to blogspot.com using something like this:
I recently posted a question about Azure... is it really an OS? I understand

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.