multiprocessing: Add, with bare Process class implementation.

pull/118/head
Paul Sokolovsky 2014-05-01 02:38:30 +03:00
rodzic 4835a37871
commit fec581f862
3 zmienionych plików z 44 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,20 @@
import os
class Process:
def __init__(self, group=None, target=None, name=None, args=(), kwargs={}):
self.target = target
self.args = args
self.pid = 0
def start(self):
self.pid = os.fork()
if not self.pid:
self.target(*self.args)
os._exit(0)
else:
return
def join(self):
os.waitpid(self.pid, 0)

Wyświetl plik

@ -0,0 +1,15 @@
import sys
# Remove current dir from sys.path, otherwise distutils will peek up our
# module instead of system.
sys.path.pop(0)
from setuptools import setup
setup(name='micropython-multiprocessing',
version='0.0.1',
description='multiprocessing module to MicroPython',
url='https://github.com/micropython/micropython/issues/405',
author='Paul Sokolovsky',
author_email='micro-python@googlegroups.com',
license='MIT',
install_requires=['micropython-os'],
py_modules=['multiprocessing'])

Wyświetl plik

@ -0,0 +1,9 @@
from multiprocessing import Process
def f(name):
print('hello', name)
if __name__ == '__main__':
p = Process(target=f, args=('bob',))
p.start()
p.join()