Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
230efcc1
Commit
230efcc1
authored
Dec 31, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use weakref for atexit handler in PrefetchDataZMQ (#562)
parent
91f3a441
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
tensorpack/dataflow/prefetch.py
tensorpack/dataflow/prefetch.py
+9
-2
No files found.
tensorpack/dataflow/prefetch.py
View file @
230efcc1
...
...
@@ -3,6 +3,7 @@
# Author: Yuxin Wu <ppwwyyxx@gmail.com>
from
__future__
import
print_function
import
weakref
import
threading
from
contextlib
import
contextmanager
import
multiprocessing
as
mp
...
...
@@ -12,6 +13,7 @@ import errno
import
uuid
import
os
import
zmq
import
atexit
from
.base
import
DataFlow
,
ProxyDataFlow
,
DataFlowTerminated
,
DataFlowReentrantGuard
from
..utils.concurrency
import
(
ensure_proc_terminate
,
...
...
@@ -49,6 +51,12 @@ def _get_pipe_name(name):
return
pipename
def
del_weakref
(
x
):
o
=
x
()
if
o
is
not
None
:
o
.
__del__
()
@
contextmanager
def
_zmq_catch_error
(
name
):
try
:
...
...
@@ -82,8 +90,7 @@ class _MultiProcessZMQDataFlow(DataFlow):
self
.
_reset_done
=
True
# __del__ not guranteed to get called at exit
import
atexit
atexit
.
register
(
lambda
x
:
x
.
__del__
(),
self
)
atexit
.
register
(
del_weakref
,
weakref
.
ref
(
self
))
self
.
_reset_once
()
# build processes
...
...
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