multiprocessing on freebsd

Philip Semanchuk philip at semanchuk.com
Wed Mar 17 16:26:51 CET 2010


On Mar 17, 2010, at 9:30 AM, Tim Arnold wrote:

> Hi,
> I'm checking to see if multiprocessing works on freebsd for any
> version of python. My server is about to get upgraded from 6.3 to 8.0
> and I'd sure like to be able to use multiprocessing.
>
> I think the minimal test would be:
> ---------------------
> import multiprocessing
> q = multiprocessing.Queue()
> ---------------------
>
> with 6.3, I get
>
> File "/usr/local/lib/python2.6/multiprocessing/__init__.py", line
> 212, in Queue
>    from multiprocessing.queues import Queue
>  File "/usr/local/lib/python2.6/multiprocessing/queues.py", line 22,
> in <module>
>    from multiprocessing.synchronize import Lock, BoundedSemaphore,
> Semaphore, Condition
>  File "/usr/local/lib/python2.6/multiprocessing/synchronize.py", line
> 33, in <module>
>    " function, see issue 3770.")
> ImportError: This platform lacks a functioning sem_open
> implementation, therefore, the required synchronization primitives
> needed will not function, see issue 3770.

Hi Tim,
Under FreeBSD 8/Python 2.6.2 I get the same result, unfortunately.  
That's a pity because sem_open works under FreeBSD >= 7.2 as we  
discussed before.


Issue 3770 is closed with the note, "we've removed hard-coded platform  
variables for a better autoconf approach." I'm using the Python built  
from FreeBSD's ports, and the note makes me think that it's possible  
that if I built my own Python from the Python.org tarball rather than  
ports the problem would go away due to autoconf magic. I don't have  
the time to offer to do this for you, unfortunately. But why not  
install FreeBSD 8 under VirtualBox or somesuch and give it a go  
yourself?

A couple of quirks I noted related to FreeBSD & POSIX IPC that you  
might find useful --
- The sem and mqueuefs kernel modules must be loaded, otherwise you'll  
get a message like this when you try to create a semaphore or message  
queue:
Bad system call: 12 (core dumped)

Under 8.0 they're loaded by default, I think.

- C apps that want to use message queues must link to the realtime  
libs (pass -lrt to the linker). This tripped me up for a while.  
Linking to the realtime libs is required for all POSIX IPC calls under  
Linux; FreeBSD does not require it for semaphores or shared mem, only  
message queues.


Hope this helps
Philip





More information about the Python-list mailing list