fork download
  1. import multiprocessing as mp
  2. import time
  3.  
  4. DELAY_SIZE = 1
  5.  
  6. def Worker(q):
  7. sleep_for = DELAY_SIZE / 10.0
  8. while True:
  9. print "I'm working... "
  10. time.sleep(sleep_for)
  11.  
  12. def Process():
  13. print " I'm processing.."
  14.  
  15. #time.sleep(10)
  16.  
  17. queue = mp.Queue(maxsize=DELAY_SIZE)
  18. p = mp.Process(target=Worker, args=(queue,))
  19. p.start()
  20.  
  21. while True:
  22. time.sleep(DELAY_SIZE)
  23. Process()
  24.  
Runtime error #stdin #stdout #stderr 0.1s 11824KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 17, in <module>
    queue = mp.Queue(maxsize=DELAY_SIZE)
  File "/usr/lib/python2.7/multiprocessing/__init__.py", line 218, in Queue
    return Queue(maxsize)
  File "/usr/lib/python2.7/multiprocessing/queues.py", line 63, in __init__
    self._rlock = Lock()
  File "/usr/lib/python2.7/multiprocessing/synchronize.py", line 147, in __init__
    SemLock.__init__(self, SEMAPHORE, 1, 1)
  File "/usr/lib/python2.7/multiprocessing/synchronize.py", line 75, in __init__
    sl = self._semlock = _multiprocessing.SemLock(kind, value, maxvalue)
OSError: [Errno 38] Function not implemented