Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
10b434ff
Commit
10b434ff
authored
9 years ago
by
Danilo Piparo
Browse files
Options
Downloads
Patches
Plain Diff
Make general and valid also for the non kernel case
parent
82ba1af0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/pyroot/JupyROOT/handlers.py
+40
-11
40 additions, 11 deletions
bindings/pyroot/JupyROOT/handlers.py
with
40 additions
and
11 deletions
bindings/pyroot/JupyROOT/
kernel/
handler.py
→
bindings/pyroot/JupyROOT/handler
s
.py
+
40
−
11
View file @
10b434ff
# -*- coding:utf-8 -*-
# -*- coding:utf-8 -*-
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Copyright (c) 2015, ROOT Team.
# Copyright (c) 2015, ROOT Team.
# Authors:
Omar Zapata <Omar.Zapata@cern.ch> http://oproject.org
# Authors:
Danilo Piparo
#
website: http://oproject.org/ROOT+Jupyter+Kernel (information only for ROOT kernel)
#
Omar Zapata <Omar.Zapata@cern.ch> http://oproject.org
# Distributed under the terms of the Modified LGPLv3 License.
# Distributed under the terms of the Modified LGPLv3 License.
#
#
# The full license is in the file COPYING.rst, distributed with this software.
# The full license is in the file COPYING.rst, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
from
__future__
import
print_function
from
ctypes
import
CDLL
,
c_char_p
from
ctypes
import
CDLL
,
c_char_p
from
threading
import
Thread
from
threading
import
Thread
from
time
import
sleep
as
timeSleep
_lib
=
CDLL
(
"
libJupyROOT.so
"
)
_lib
=
CDLL
(
"
libJupyROOT.so
"
)
...
@@ -43,27 +46,40 @@ class IOHandler(object):
...
@@ -43,27 +46,40 @@ class IOHandler(object):
def
GetStderr
(
self
):
def
GetStderr
(
self
):
return
_GetStream
(
_lib
.
JupyROOTExecutorHandler_GetStderr
)
return
_GetStream
(
_lib
.
JupyROOTExecutorHandler_GetStderr
)
def
GetStreamsDicts
(
self
):
out
=
self
.
GetStdout
()
err
=
self
.
GetStderr
()
outDict
=
{
'
name
'
:
'
stdout
'
,
'
text
'
:
out
}
if
out
!=
""
else
None
errDict
=
{
'
name
'
:
'
stderr
'
,
'
text
'
:
err
}
if
err
!=
""
else
None
return
outDict
,
errDict
class
Runner
(
object
):
class
Runner
(
object
):
def
__init__
(
self
,
function
):
def
__init__
(
self
,
function
):
self
.
function
=
function
self
.
function
=
function
self
.
thread
=
None
def
Run
(
self
,
argument
):
def
Run
(
self
,
argument
):
return
self
.
function
(
argument
)
return
self
.
function
(
argument
)
def
AsyncRun
(
self
,
argument
):
def
AsyncRun
(
self
,
argument
):
self
.
thread
=
threading
.
Thread
(
target
=
self
.
Run
,
args
=
(
argument
,))
self
.
thread
=
Thread
(
target
=
self
.
Run
,
args
=
(
argument
,))
self
.
thread
.
start
()
self
.
thread
.
start
()
def
Wait
(
self
):
if
not
self
.
thread
:
return
self
.
thread
.
join
()
def
HasFinished
(
self
):
def
HasFinished
(
self
):
finished
=
False
if
not
self
.
thread
:
return
True
if
self
.
thread
:
finished
=
not
self
.
thread
.
is_alive
()
finished
=
not
self
.
thread
.
is_alive
()
if
not
finished
:
return
False
self
.
thread
.
join
()
self
.
thread
=
None
if
finished
:
return
True
self
.
thread
.
join
()
self
.
thread
=
None
return
finished
class
JupyROOTDeclarer
(
Runner
):
class
JupyROOTDeclarer
(
Runner
):
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -73,3 +89,16 @@ class JupyROOTExecutor(Runner):
...
@@ -73,3 +89,16 @@ class JupyROOTExecutor(Runner):
def
__init__
(
self
):
def
__init__
(
self
):
super
(
JupyROOTExecutor
,
self
).
__init__
(
_lib
.
JupyROOTExecutor
)
super
(
JupyROOTExecutor
,
self
).
__init__
(
_lib
.
JupyROOTExecutor
)
def
RunAsyncAndPrint
(
executor
,
code
,
ioHandler
,
printFunction
,
silent
=
False
,
timeout
=
0.1
):
ioHandler
.
Clear
()
ioHandler
.
InitCapture
()
executor
.
AsyncRun
(
code
)
while
not
executor
.
HasFinished
():
ioHandler
.
Clear
()
ioHandler
.
Poll
()
if
not
silent
:
printFunction
(
ioHandler
)
if
executor
.
HasFinished
():
break
timeSleep
(.
1
)
executor
.
Wait
()
ioHandler
.
EndCapture
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment