KeyboardInterrupt starts expensive background process
ulfaslak opened this issue · 28 comments
This is a weird one. When I KeyboardInterrupt
in a Jupyter Notebook, a very CPU hungry Python process starts.
When I restart the kernel, it terminates. If I terminate it in the activity monitor, the Jupyter kernel becomes busy (no output in terminal).
Even weirder, if I launch a new visualization, IT STOPS.
possibly fixed (forgot thread.join()). Can you try?
Sorry, baby fog, will try later!
Alright, it was fast enough to try. So I upgraded with pip to v0.0.6 (right one?), but the bug is still there.
ah on sec
ok i'm not being very thorough checking if I installed it right here, but downloading the repo and running python setup.py install
it installs v 0.0.7, which also imports successfully, but throws the error DistutilsFileError: cannot copy tree '/anaconda3/lib/python3.7/site-packages/netwulf-0.0.7-py3.7.egg/netwulf/js': not a directory
at visualize(G)
is this fixed by now? 🤔
can't reproduce
This still happens to me. It's driving me crazy. Also, connected to this, the POST back to Python feature doesn't work. I'll look into this further and we can probably close this for now but jeeeeeesus....
It seems to everything right down to line 274 if interactive.py where it hangs on thread.join()
.
I reopen this ... you won't be the only one having this problem
This is the output when hitting "Post to Python" and then upon returning to the notebook (where the kernel is still busy), interrupting the kernel:
changing directory to /Users/ulfaslak/.netwulf
starting server here ... /Users/ulfaslak/.netwulf
127.0.0.1 09/Apr/2019 14:17:27 GET /?data=tmp_16a02081db3.json&config=config_tmp_16a02081db3.json HTTP/1.1 200 -
127.0.0.1 09/Apr/2019 14:17:28 GET /config_tmp_16a02081db3.json HTTP/1.1 200 -
127.0.0.1 09/Apr/2019 14:17:28 GET /tmp_16a02081db3.json HTTP/1.1 200 -
127.0.0.1 09/Apr/2019 14:17:29 POST /?data=tmp_16a02081db3.json&config=config_tmp_16a02081db3.json HTTP/1.1 200 -
Successfully posted network data to Python!
127.0.0.1 09/Apr/2019 14:17:31 POST /?data=tmp_16a02081db3.json&config=config_tmp_16a02081db3.json HTTP/1.1 200 -
stopping server ...
was asked to stop the server
deleted all files
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-6-a227c1684ca5> in <module>
6 v['group'] = v['block']; del v['block']
7
----> 8 visualize(G, verbose=True)
/anaconda3/lib/python3.7/site-packages/netwulf/interactive.py in visualize(network, port, verbose, config)
272 print('stopping server ...')
273 server.stop_this()
--> 274 thread.join()
275
276 posted_network_properties = server.posted_network_properties
/anaconda3/lib/python3.7/threading.py in join(self, timeout)
1030
1031 if timeout is None:
-> 1032 self._wait_for_tstate_lock()
1033 else:
1034 # the behavior of a negative timeout isn't documented, but
/anaconda3/lib/python3.7/threading.py in _wait_for_tstate_lock(self, block, timeout)
1046 if lock is None: # already determined that the C code is done
1047 assert self._is_stopped
-> 1048 elif lock.acquire(block, timeout):
1049 lock.release()
1050 self._stop()
KeyboardInterrupt:
I'm on Python 3.7.3, and netwulf version 0.0.14
can you try with the latest commit? I'm pretty sure it won't work but a guy can dream
I like your spirit but no cigar. Also, this never runs if you don't interrupt (click Post to Python in webapp)
Can it have something to do with the http.serve_forever()
line? And that it excepts OSError
s? I tried removing the try-except clause, and nothing happened, but still as I understand it, thread.join()
is ineffective because thread
is still busy.
Recall that everything runs smoothly down to and including line 273: server.stop_this()
Cool thanks. No stress, just got hung up on this now...
I've added a timeout to thread.join()
-- can you try again with the new commit?
I now added a functionality which stops serve_forever