Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
neoppod
Commits
875fc1b9
Commit
875fc1b9
authored
Jan 04, 2018
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug: add helper to run code outside the signal handler
parent
a414f91f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
15 deletions
+29
-15
neo/debug.py
neo/debug.py
+29
-15
No files found.
neo/debug.py
View file @
875fc1b9
...
@@ -9,6 +9,32 @@ The prompt is accessible through network in case that the process is daemonized:
...
@@ -9,6 +9,32 @@ The prompt is accessible through network in case that the process is daemonized:
<neo.master.app.Application object at 0x1fc9750>
<neo.master.app.Application object at 0x1fc9750>
"""
"""
import
sys
def
app_set
():
try
:
return
sys
.
modules
[
'neo.lib.threaded_app'
].
app_set
except
KeyError
:
f
=
sys
.
_getframe
(
4
)
try
:
while
f
.
f_code
.
co_name
!=
'run'
or
\
f
.
f_locals
.
get
(
'self'
).
__class__
.
__name__
!=
'Application'
:
f
=
f
.
f_back
return
f
.
f_locals
[
'self'
],
except
AttributeError
:
return
()
def
defer
(
task
):
def
wrapper
():
from
traceback
import
print_exc
try
:
task
(
app
)
except
:
print_exc
()
for
app
in
app_set
():
app
.
em
.
wakeup
(
wrapper
)
break
IF
=
'pdb'
IF
=
'pdb'
if
IF
==
'pdb'
:
if
IF
==
'pdb'
:
# List of (module, callables) to break at.
# List of (module, callables) to break at.
...
@@ -19,7 +45,7 @@ if IF == 'pdb':
...
@@ -19,7 +45,7 @@ if IF == 'pdb':
#('ZPublisher.Publish', 'publish_module_standard'),
#('ZPublisher.Publish', 'publish_module_standard'),
)
)
import
errno
,
socket
,
sys
,
threading
,
weakref
import
errno
,
socket
,
threading
,
weakref
# Unfortunately, IPython does not always print to given stdout.
# Unfortunately, IPython does not always print to given stdout.
#from neo.lib.debug import getPdb
#from neo.lib.debug import getPdb
from
pdb
import
Pdb
as
getPdb
from
pdb
import
Pdb
as
getPdb
...
@@ -82,19 +108,7 @@ if IF == 'pdb':
...
@@ -82,19 +108,7 @@ if IF == 'pdb':
getPdb
(
stdin
=
_socket
,
stdout
=
_socket
).
set_trace
()
getPdb
(
stdin
=
_socket
,
stdout
=
_socket
).
set_trace
()
app
# this is Application instance (see 'app_set' if there are several)
app
# this is Application instance (see 'app_set' if there are several)
try
:
app_set
=
app_set
()
app_set
=
sys
.
modules
[
'neo.lib.threaded_app'
].
app_set
except
KeyError
:
f
=
sys
.
_getframe
(
3
)
try
:
while
f
.
f_code
.
co_name
!=
'run'
or
\
f
.
f_locals
.
get
(
'self'
).
__class__
.
__name__
!=
'Application'
:
f
=
f
.
f_back
app_set
=
f
.
f_locals
[
'self'
],
except
AttributeError
:
app_set
=
()
finally
:
del
f
class
setupBreakPoints
(
list
):
class
setupBreakPoints
(
list
):
...
@@ -144,7 +158,7 @@ if IF == 'pdb':
...
@@ -144,7 +158,7 @@ if IF == 'pdb':
threading
.
Thread
(
target
=
pdb
).
start
()
threading
.
Thread
(
target
=
pdb
).
start
()
elif
IF
==
'frames'
:
elif
IF
==
'frames'
:
import
sys
,
traceback
import
traceback
write
=
sys
.
stderr
.
write
write
=
sys
.
stderr
.
write
for
thread_id
,
frame
in
sys
.
_current_frames
().
iteritems
():
for
thread_id
,
frame
in
sys
.
_current_frames
().
iteritems
():
write
(
"Thread %s:
\
n
"
%
thread_id
)
write
(
"Thread %s:
\
n
"
%
thread_id
)
...
...
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