[New-bugs-announce] [issue42730] TypeError in Time.Sleep when invoked from shell script background

Abdulrahman Alabdulkareem report at bugs.python.org
Thu Dec 24 12:29:09 EST 2020


New submission from Abdulrahman Alabdulkareem <master3243 at gmail.com>:

I get a random TypeError exception thrown whenever I interrupt/kill a sleeping parent thread from a child thread but ONLY if the python script was invoked by a shell script with an & argument to make it run in the background. (this is in vanilla python)

This doesn't happen if invoked 

(1) in command line
(2) in command line with &
(3) in shell script (without &)

Only in shell script with &.

Here is the python script named psc.py https://pastebin.com/raw/KZQptCMr
And here is the shell script named ssc.sh https://pastebin.com/raw/QQzs4Tpz that when ran will run the python script and cause the strange behaviour

Here is the output I'm seeing: -------------------
parent looping
child interrupting parent
why would I ever catch a TypeError?
Traceback (most recent call last):
  File "m.py", line 17, in <module>
    time.sleep(1)
TypeError: 'int' object is not callable

Here is the output I'm expecting: --------------------
parent looping
child interrupting parent
caught interruption raised from user or child thread :)

Another unexpected behaviour might be that python suddenly hangs.

Here is a stackoverflow question raised on this issue with discussion in the comments https://stackoverflow.com/questions/65440353/python-time-sleep1-raises-typeerror?noredirect=1#comment115697237_65440353

----------
messages: 383695
nosy: master3243
priority: normal
severity: normal
status: open
title: TypeError in Time.Sleep when invoked from shell script background
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42730>
_______________________________________


More information about the New-bugs-announce mailing list