-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
Closed
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Description
Bug report
Bug description:
rlocktesting.py:
from _thread import start_new_thread,RLock
from select import select
from os import write
from signal import signal,SIGALRM,alarm
lock=RLock()
def threadfunc():
write(1,b"thread: trying to acquire lock\n")
lock.acquire()
write(1,b"thread: acquired lock and doing unrelated stuff for 3 seconds\n")
select((),(),(),3)
write(1,b"thread: trying to release lock\n")
lock.release()
write(1,b"thread: released lock\n")
def SIGALRMhandler(signum,frame):
write(1,b"SIGALRM: trying to acquire lock\n")
lock.acquire()
write(1,b"SIGALRM: acquired lock, returning\n")
signal(SIGALRM,SIGALRMhandler)
start_new_thread(threadfunc,())
alarm(2)
write(1,b"main: doing unrelated stuff for 1 second\n")
select((),(),(),1)
write(1,b"main: trying to acquire lock\n")
lock.acquire()#global scope
write(1,b"main: acquired lock\nEND OF USELESS PROGRAM\n")running:
$ python3 rlocktesting.py
main: doing unrelated stuff for 1 second
thread: trying to acquire lock
thread: acquired lock and doing unrelated stuff for 3 seconds
main: trying to acquire lock
SIGALRM: trying to acquire lock
thread: trying to release lock
thread: released lock
SIGALRM: acquired lock, returningit gets stuck forever, pressing ctrl+c:
^CTraceback (most recent call last):
File "/tmp/rlocktesting.py", line 28, in <module>
lock.acquire()#global scope
~~~~~~~~~~~~^^
KeyboardInterruptI excpeted main thread to successfully acquire lock twice (first inside SIGALRMhandler, second continuing inside global scope)
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Projects
Status
Todo