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
Threading problems in Python Interpreter #1116
Comments
There are in fact two issues:
Workaround import sys
sys.stdout.reconfigure(line_buffering=True, write_through=False) |
Thanx, it works 99% but it is nice workarround
Jadranko Belušić
[image: https://www.linkedin.com/in/jadranko-belu%C5%A1i%C4%87-818231176/]
<https://www.linkedin.com/in/jadranko-belu%C5%A1i%C4%87-818231176/>
sri, 12. svi 2021. u 00:04 pyscripter ***@***.***> napisao je:
… There are in fact two issues:
-
Line buffering
Python by default does line buffering of stdout . This means that
output is printed when it contains a new line /n. PyScripter v,4 gets the
output via redirection using pipes, but in that case python detects that it
is not writing to a console and disables line buffering. To get the output
PyScripter had to run the python process with -u flag which disables
buffering altogether. This is not an issue with single threaded scripts,
but it results in the problem which you experienced when different threads
print simultaneously. Python 3.7 and later allow you to reconfigure the
stdout and this is now implemented and line buffering should be available
with Python 3.7 and later. The fix will be available in the next release of
PyScripter.
-
daemon threads
When you run a script with daemon threads, the daemon threads stop
when all other threads terminate. However the way PyScripter runs scripts,
Python does not terminate when the main thread exits. This has many
advantages (post-mortem analysis, allowing you to query the state of
variables etc.). A downside is that daemon threads will carry on running
until you re-initialize the interpreter, by say running a new script. This
is by design, and just a gotcha you need to be aware of. No fix will be
provided for this.
*Workaround*
Assuming that you use python 3.7 or newer a workaround is to include the
following at the top of your script:
import syssys.stdout.reconfigure(line_buffering=True, write_through=False)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1116 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHBV62UG444ZW7DEQN2R66LTNGSXDANCNFSM44KR34HQ>
.
|
I can't see the image. You can copy and paste the image in github. |
No matter what, I found this IDE the best for now! Thanx for such a great tool! |
it is correct given my comment about daemon threads. If you run your script in a python interpreter the daemon thread should stop when main exits. |
It works, thank you!
sri, 12. svi 2021. 22:45 pyscripter ***@***.***> je napisao:
… it is correct given my comment about daemon threads. If you run your
script in a python interpreter the daemon thread should stop when main
exits.
With Pyscripter avoid daemon threads and try to join the threads before
exiting main.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1116 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHBV62SW5YESVTVAFNYWZBLTNLSFNANCNFSM44KR34HQ>
.
|
This is script to be executed:
The text was updated successfully, but these errors were encountered: