Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
eb64af92
Commit
eb64af92
authored
May 09, 2003
by
Just van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add explicit support for cancelling a running script (CFM-based MacPython had this built-in)
parent
476736ee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
2 deletions
+25
-2
Mac/Tools/IDE/PyEdit.py
Mac/Tools/IDE/PyEdit.py
+25
-2
No files found.
Mac/Tools/IDE/PyEdit.py
View file @
eb64af92
...
...
@@ -619,16 +619,39 @@ class Editor(W.Window):
savedir
=
os
.
getcwd
()
os
.
chdir
(
dir
)
sys
.
path
.
insert
(
0
,
dir
)
else
:
cwdindex
=
None
self
.
_scriptDone
=
False
if
sys
.
platform
==
"darwin"
:
# On MacOSX, MacPython doesn't poll for command-period
# (cancel), so to enable the user to cancel a running
# script, we have to spawn a thread which does the
# polling. It will send a SIGINT to the main thread
# (in which the script is running) when the user types
# command-period.
from
threading
import
Thread
t
=
Thread
(
target
=
self
.
_userCancelledMonitor
,
name
=
"UserCancelledMonitor"
)
t
.
start
()
try
:
execstring
(
pytext
,
globals
,
locals
,
file
,
self
.
debugging
,
modname
,
self
.
profiling
)
finally
:
self
.
_scriptDone
=
True
if
self
.
path
:
os
.
chdir
(
savedir
)
del
sys
.
path
[
0
]
def
_userCancelledMonitor
(
self
):
import
time
from
signal
import
SIGINT
while
not
self
.
_scriptDone
:
if
Evt
.
CheckEventQueueForUserCancel
():
# Send a SIGINT signal to ourselves.
# This gets delivered to the main thread,
# cancelling the running script.
os
.
kill
(
os
.
getpid
(),
SIGINT
)
break
time
.
sleep
(
0.25
)
def
getenvironment
(
self
):
if
self
.
path
:
file
=
self
.
path
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment