Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
d36093ef
Commit
d36093ef
authored
Aug 21, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Example of neo/debug.py script starting a debugger on RTMIN+2 signal
parent
07efb0ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
0 deletions
+73
-0
neo/debug.py
neo/debug.py
+73
-0
No files found.
neo/debug.py
0 → 100644
View file @
d36093ef
"""Example of script starting a debugger on RTMIN+2 signal
The pdb is launched in a separate thread in order not to trigger timeouts.
The prompt is accessible through network in case that the process is daemonized:
$ socat READLINE TCP:127.0.0.1:54930
> neo/debug.py(63)pdb()
-> app # this is Application instance
(Pdb) app
<neo.master.app.Application object at 0x1fc9750>
"""
if
1
:
import
socket
,
sys
,
threading
#from neo.lib.debug import getPdb
from
pdb
import
Pdb
as
getPdb
class
Socket
(
object
):
def
__init__
(
self
,
socket
):
self
.
_socket
=
socket
self
.
_buf
=
''
def
write
(
self
,
data
):
self
.
_socket
.
send
(
data
)
def
readline
(
self
):
recv
=
self
.
_socket
.
recv
data
=
self
.
_buf
while
True
:
i
=
1
+
data
.
find
(
'
\
n
'
)
if
i
:
self
.
_buf
=
data
[
i
:]
return
data
[:
i
]
d
=
recv
(
4096
)
data
+=
d
if
not
d
:
self
.
_buf
=
''
return
data
def
flush
(
self
):
pass
def
closed
(
self
):
self
.
_socket
.
setblocking
(
0
)
try
:
self
.
_socket
.
recv
(
0
)
return
True
except
socket
.
error
,
(
err
,
_
):
if
err
!=
errno
.
EAGAIN
:
raise
self
.
_socket
.
setblocking
(
1
)
return
False
def
pdb
(
app
):
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
try
:
s
.
bind
((
'127.0.0.1'
,
0
))
s
.
listen
(
0
)
print
'Listening to %u'
%
s
.
getsockname
()[
1
]
_socket
=
Socket
(
s
.
accept
()[
0
])
finally
:
s
.
close
()
getPdb
(
stdin
=
_socket
,
stdout
=
_socket
).
set_trace
()
app
# this is Application instance
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
threading
.
Thread
(
target
=
pdb
,
args
=
(
f
.
f_locals
[
'self'
],)).
start
()
finally
:
del
f
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