Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
ed1948b5
Unverified
Commit
ed1948b5
authored
Jan 12, 2019
by
Lingfan Yu
Committed by
GitHub
Jan 12, 2019
Browse files
[BugFix] Make program thread-local to support multi-threading (#338)
* make program thread local * doc string
parent
19e1b140
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
+18
-5
python/dgl/runtime/ir/program.py
python/dgl/runtime/ir/program.py
+18
-5
No files found.
python/dgl/runtime/ir/program.py
View file @
ed1948b5
...
...
@@ -2,6 +2,7 @@
from
__future__
import
absolute_import
from
contextlib
import
contextmanager
import
threading
from
.registry
import
IR_REGISTRY
...
...
@@ -44,18 +45,30 @@ class Prog(object):
for
exe
in
self
.
execs
:
self
.
pprint_exe
(
exe
)
class
CurrentProgram
(
threading
.
local
):
"""Thread local storage to keep the reference of current thread's program"""
def
__init__
(
self
):
super
(
CurrentProgram
,
self
).
__init__
()
self
.
prog
=
None
def
get_prog
(
self
):
"""Get program"""
return
self
.
prog
def
set_prog
(
self
,
program
):
"""Set program"""
self
.
prog
=
program
# current program
CURRENT_PROG
=
None
CURRENT_PROG
=
CurrentProgram
()
def
get_current_prog
():
"""Get the current program."""
global
CURRENT_PROG
return
CURRENT_PROG
return
CURRENT_PROG
.
get_prog
()
def
set_current_prog
(
program
):
"""Set the current program."""
global
CURRENT_PROG
CURRENT_PROG
=
program
CURRENT_PROG
.
set_prog
(
program
)
@
contextmanager
def
prog
():
...
...
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