Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jython process doesn't terminate #11

Closed
trofimander opened this issue Aug 27, 2014 · 5 comments
Closed

Jython process doesn't terminate #11

trofimander opened this issue Aug 27, 2014 · 5 comments

Comments

@trofimander
Copy link
Collaborator

Steps to reproduce:

  • Run some trivial script under debug with Jython 2.5.4rc1 like
x = 1 
print (x)

Result:

  • The process hangs forever until terminated manually
@fabioz
Copy link
Owner

fabioz commented Aug 28, 2014

Note: this happens because of a Jython bug:

def func():
import threading
print threading.currentThread().isDaemon() # That version of Jython says its not daemon when it should be!

thread.start_new_thread(func, ())

Still checking a workaround...

@fabioz
Copy link
Owner

fabioz commented Aug 28, 2014

Fixed in bbf5251

@fabioz fabioz closed this as completed Aug 28, 2014
@trofimander
Copy link
Collaborator Author

True. I've just checked it.
The thing I don't understand why is it daemon in CPython? Documentation says that main thread is not daemon, as well as all other threads started from main thread are not by default.
So it is rather bug in CPython old API then in Jython.

@fabioz
Copy link
Owner

fabioz commented Aug 28, 2014

Well, the docs say mostly about threading.Thread, but the thread.start_new_thread doesn't create an entry in the threads, so, if you call threading.currentThread() in that case it returns a dummy thread...

Which has in its implementation the following note:

Dummy thread class to represent threads not started here.
These aren't garbage collected when they die, nor can they be waited for.
If they invoke anything in threading.py that calls current_thread(), they
leave an entry in the _active dict forever after.
Their purpose is to return something from current_thread().
They are marked as daemon threads so we won't wait for them
when we exit (conform previous semantics).

@trofimander
Copy link
Collaborator Author

Thanks for the clarification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants