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 6136467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:36:23+00:00 2026-05-23T17:36:23+00:00

modules exists inside new processes before import, using python-multiprocessing on osx. Here’s an example:

  • 0

modules exists inside new processes before import, using python-multiprocessing on osx.
Here’s an example:


import multiprocessing
import sys
import os

print 'importing module'
def main():
    import uuid
    print 'setting var'
    uuid.some_variable = True

def process(name):
    print 'uuid module loaded:', 'uuid' in sys.modules
    print 'process pid', os.getpid()
    import uuid
    var = uuid.some_variable
    print 'var exists on mac', var

if __name__ == '__main__':
    print 'main pid', os.getpid()
    main()
    p = multiprocessing.Process(target=process, args=('test',))
    p.start()
    p.join()

output on windows/linux is what I would expect. The script import twice, uuid.some_variable does not exists, and uuid is not loaded before import:

importing module
main pid 4352
setting var
importing module
uuid module loaded: False
process pid 4988
AttributeError: 'module' object has no attribute 'some_variable'

However on osx, the script will only import once, uuid is loaded before import, and uuid.some_variable exists in the new process:

importing module
main pid 4399
setting var
uuid module loaded: True
process pid 4400
var exists on mac True

Somehow, the uuid module from the main process gets into the sub-process, without importing it.
Am I missing something, is this a bug, or does mac have a good reason to do this?
How did the module even get into the subprocess?

  • 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-23T17:36:24+00:00Added an answer on May 23, 2026 at 5:36 pm

    The problem is that multiprocessing uses os.fork on unix. So the sub-process becomes a copy of the main process. Dont know what’s going on with Fedora, but it shouldn’t work on linux either.
    There doesn’t seem to be any easy way to get around it.

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

Sidebar

Related Questions

In Windows, the ctypes.cdll.msvcrt object automatically exists when I import the ctypes module, and
I am looking for hexagonal self-organizing map on Python. ready module. If one exists.
I've used several modules to make EXEs for Python, but I'm not sure if
I am tracking page views within modules using the following table: id | page_id
I have a large application (~50 modules) using a structure similar to the following:
I'm using Kohana 3 and have a /doctrine/Entites folder with my entities inside. When
I have started to write a Python 3.x client application. The server application exists
I'm breaking my grails application into modules by using plugins and then adding the
Can using Modules or Shared/Static references to the BLL/DAL improve the performance of an
I am new to Django and Python. I have created a python file in

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.