Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions test/openjd/sessions_v0/support_files/app_20s_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@
# Hook SIGTERM (posix) or CTRL_BREAK_EVENT (windows) and print "Trapped"
# and exit if we get the signal

import os
import signal
import sys
import time


def hook(handle, frame):
print("Trapped")
sys.stdout.flush()
# os.write(2) rather than print() + flush(): a signal handler can interrupt
# the main loop *inside* sys.stdout.flush(), and re-entering the same
# BufferedWriter raises
# RuntimeError: reentrant call inside <_io.BufferedWriter name='<stdout>'>
# which loses this message and exits non-zero. write(2) is unbuffered, so it
# cannot re-enter. Every print here is flushed immediately, so nothing is
# sitting in the buffer for this to appear out of order with.
os.write(1, b"Trapped\n")
sys.exit(1)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@

# As app_20s_run.py except it does not exit when it gets a SIGTERM/SIGBREAK

import os
import signal
import sys
import time


def hook(handle, frame):
print("Trapped")
sys.stdout.flush()
# os.write(2) rather than print() + flush(): a signal handler can interrupt
# the main loop *inside* sys.stdout.flush(), and re-entering the same
# BufferedWriter raises
# RuntimeError: reentrant call inside <_io.BufferedWriter name='<stdout>'>
# which loses this message and exits non-zero. write(2) is unbuffered, so it
# cannot re-enter. Every print here is flushed immediately, so nothing is
# sitting in the buffer for this to appear out of order with.
os.write(1, b"Trapped\n")


if sys.platform.startswith("win"):
Expand Down
11 changes: 9 additions & 2 deletions test/openjd/sessions_v1/support_files/app_20s_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@
# Hook SIGTERM (posix) or CTRL_BREAK_EVENT (windows) and print "Trapped"
# and exit if we get the signal

import os
import signal
import sys
import time


def hook(handle, frame):
print("Trapped")
sys.stdout.flush()
# os.write(2) rather than print() + flush(): a signal handler can interrupt
# the main loop *inside* sys.stdout.flush(), and re-entering the same
# BufferedWriter raises
# RuntimeError: reentrant call inside <_io.BufferedWriter name='<stdout>'>
# which loses this message and exits non-zero. write(2) is unbuffered, so it
# cannot re-enter. Every print here is flushed immediately, so nothing is
# sitting in the buffer for this to appear out of order with.
os.write(1, b"Trapped\n")
sys.exit(1)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@

# As app_20s_run.py except it does not exit when it gets a SIGTERM/SIGBREAK

import os
import signal
import sys
import time


def hook(handle, frame):
print("Trapped")
sys.stdout.flush()
# os.write(2) rather than print() + flush(): a signal handler can interrupt
# the main loop *inside* sys.stdout.flush(), and re-entering the same
# BufferedWriter raises
# RuntimeError: reentrant call inside <_io.BufferedWriter name='<stdout>'>
# which loses this message and exits non-zero. write(2) is unbuffered, so it
# cannot re-enter. Every print here is flushed immediately, so nothing is
# sitting in the buffer for this to appear out of order with.
os.write(1, b"Trapped\n")


if sys.platform.startswith("win"):
Expand Down
Loading