add support for os.fork and related functions#4877
Conversation
|
Okay, this is functional now, code snippet: import os
def before():
print("before")
def parent():
print("parent")
def child():
print("Child")
os.register_at_fork(before=before, after_in_child=child, after_in_parent=parent)
os.fork()in rustpython In cpython ( 3.12.0a7+) wrt to error handling: rustpython cpython Some obvious review changes are needed for:
Pending: test cases
in test_waitpid, it shows # TODO: RUSTPYTHON (AttributeError: module 'os' has no attribute 'spawnv') |
Sorry, something went wrong.
|
Nice start! Some initial things so we get a better picture.
|
Sorry, something went wrong.
Co-authored-by: fanninpm <fanninpm@miamioh.edu>
|
I suspect something in |
Sorry, something went wrong.
Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
Thanks for looking this up. I knew that would be error but couldn't see it and hence couldn't add skip tag.
Yes, but I don't know why it didn't got captured at output I even added sleep(60) at child so that I could send all chunk of traceback. Probably, just UI issue on github action as it worked fine for you. |
Sorry, something went wrong.
|
I have made required changes (adding missing XXX RustPython and using #[derive(FromArgs)]) |
Sorry, something went wrong.
Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
|
Made required changes, optional arg is working fine as well. working without any issue |
Sorry, something went wrong.
Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
youknowone
left a comment
There was a problem hiding this comment.
Thank you! You made a big step on fork.
I wonder how many more features needed for gunicorn.
Sorry, something went wrong.
Thanks a lot for review and helping me with this PR. |
Sorry, something went wrong.
Motivation: I was trying to run small python server using gunicorn but it failed giving me error fork is not found in module os. This motivated me to add this feature because a running a web server is big deal (for me, atleast)
This patch add fork via libc and test cases from test_os.py
Output is as follows:
In cpython
Current challenges:
implementation of function register_at_fork
I am not entirely sure how to translate cpython's os_register_at_fork_impl to rustpython (suggestions are strongly welcome).