[Python-ideas] fork
Sven R. Kunze
srkunze at mail.de
Tue Aug 11 15:54:28 CEST 2015
Hi everybody,
I finally managed to implement all the tiny little details of fork that were important from my perspective (cf. https://pypi.python.org/pypi/xfork).
An interesting piece of code is the iterative evaluation of OperationFuture using generators to avoid stack overflows.
The only thing I am not satisfied with is exception handling. In spite of preserving the original traceback, when the ResultEvaluationError is thrown is unfortunately up to the evalutor. Maybe, somebody here has a better idea or compromise here.
Co-workers proposed using function scopes as the ultimate evaluation scope. That is when a function returns a ResultProxy, it gets evaluated. However, I have absolutely no idea how to do this as I couldn't find any __returned__ hook or something.
I learned from writing this module and some key insights I would like to share:
1) Pickle not working with decorated functions
2) One 'traceback' is not like another. There are different concepts in Python with the same name.
3) Tracebacks are not really first-class, thus customizing them is hard/impossible.
4) contextlib.contextmanager only creates decorators/context managers with parameters but what if you have none? @decorator() looks weird.
5) Generators can be used for operation evaluation to avoid the stack limit
6) Python is awesome: despite the above obstacles, I managed to hammer out a short and comprehensible implementation for fork.
It would be great if experts here could fix 1) - 4). 1) - 3) have corresponding StackOverflow threads.
@_Andrew_
I am going to address you questions shortly after this.
Best,
Sven
-------------------------------------------------------------------------------------------------
FreeMail powered by mail.de - MEHR SICHERHEIT, SERIOSITÄT UND KOMFORT
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150811/063fb38a/attachment.html>
More information about the Python-ideas
mailing list