Please check this python code:
#!/usr/bin/env python
import requests
import multiprocessing
from time import sleep, time
from requests import async
def do_req():
r = requests.get("http://w3c.org/")
def do_sth():
while True:
sleep(10)
if __name__ == '__main__':
do_req()
multiprocessing.Process( target=do_sth, args=() ).start()
When I press Ctrl-C (wait 2sec after run - let Process run), it doesn't stop. When I change the import order to:
from requests import async
from time import sleep, time
it stops after Ctrl-C. Why it doesn't stop/kill in first example?
It's a bug or a feature?
Notes:
- Yes I know, that I didn't use async in this code, this is just stripped down code. In real code I use it. I did it to simplify my question.
- After pressing Ctrl-C there is a new (child) process running. Why?
multiprocessing.__version__ == 0.70a1
,requests.__version__ == 0.11.2
,gevent.__version__ == 0.13.7