kuralabs / multiexit Goto Github PK
View Code? Open in Web Editor NEWatexit replacement that supports multiprocessing
License: Apache License 2.0
atexit replacement that supports multiprocessing
License: Apache License 2.0
If you kill the main process with ctrl+c
multiexit fails to handle termination
Python's atexit is designed, so that func gets called when
At normal program termination (for instance, if sys.exit() is called or the main module’s execution completes
But with multiexit, func only gets called on termination by a signal, not on simple module completion!
The handler is not getting called, neither on Linux or windows. Should there be more signals to add ?
Hi,
First of all, thank you for making multiexit :)
I was wondering if it was possible to register ()
a function with one argument?
Here is an example :
#!/usr/bin/env python
# coding: utf-8
import requests
from multiexit import install, register, unregister, run_exitfuncs
#import multiexit
from os import getpid
import signal
install(signals=(signal.SIGTERM, signal.SIGINT),except_hook=True)
def shared_exit():
print('Shared exit being called by {} ...'.format(getpid()))
register(shared_exit, shared=True)
@register
def test_get(url):
response = requests.request("GET", url)
print(response.status_code)
#global url
url = 'https://duckduckgo.com/?q=plop&t=h_&ia=definition'
raise Exception('My error!')
Currently, this does not seem to work, the agurment
is not passing to the function and we have this error:
Uncaught exception
Traceback (most recent call last):
File "plop.py", line 27, in <module>
raise Exception('My error!')
Exception: My error!
Exit function <function test_get at 0x7f64ad61cd08> failed:
Traceback (most recent call last):
File "/data/[user]/home/.local/share/virtualenvs/venv_test_3.6.9/lib/python3.6/site-packages/multiexit.py", line 75, in run_exitfuncs
func()
TypeError: test_get() missing 1 required positional argument: 'url'
Shared exit being called by 24182 ...
Maybe it's not possible or it's against the ideology of this module ?
I'm happy to contribute a PR if we agree on a solution and you guys think
it's worth doing.
Hello, I am trying to build this library for multiprocessing
https://github.com/devxpy/zproc
It currently claims that
Remembers to kill processes when exiting, for general peace.
But I noticed that processes that are spawned from inside another process dont get cleaned up properly.
Only those processes that were spawned from the parent are cleaned up.
I am currently using atexit to register cleanup using os.kill()
(registered as soon as you spawn a new Process.). You may see the corresponding code here and here.
This is my cleanup function.
Do you think this lib will be able to help me with this?
Doesn't seem to work from inside classes.
@multiexit.register
File "/redacted/redacted/redacted/venv/lib/python3.6/site-packages/multiexit.py", line 168, in register
current_handler,
RuntimeError: multiexit signal handler isn't installed. Unknown signal handler 0. Please call install() once on the maim process before starting any subprocess.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.