Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hidra
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
Container Registry
Model registry
Operate
Environments
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
Show more breadcrumbs
steinbac
hidra
Commits
251abb09
Commit
251abb09
authored
9 years ago
by
Manuela Kuhn
Browse files
Options
Downloads
Patches
Plain Diff
Desroy context only if it is created inside the class
parent
215b00a9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ZeroMQTunnel/Cleaner.py
+12
-3
12 additions, 3 deletions
src/ZeroMQTunnel/Cleaner.py
src/ZeroMQTunnel/sender.py
+18
-7
18 additions, 7 deletions
src/ZeroMQTunnel/sender.py
with
30 additions
and
10 deletions
src/ZeroMQTunnel/Cleaner.py
+
12
−
3
View file @
251abb09
...
...
@@ -38,6 +38,7 @@ class Cleaner():
bindingPortForSocket
=
None
bindingIpForSocket
=
None
zmqContextForCleaner
=
None
externalContext
=
None
# if the context was created outside this class or not
zmqCleanerSocket
=
None
# to get the logging only handling this class
...
...
@@ -46,9 +47,15 @@ class Cleaner():
def
__init__
(
self
,
targetPath
,
bindingIp
=
"
127.0.0.1
"
,
bindingPort
=
"
6062
"
,
context
=
None
,
verbose
=
False
):
self
.
bindingPortForSocket
=
bindingPort
self
.
bindingIpForSocket
=
bindingIp
self
.
zmqContextForCleaner
=
context
or
zmq
.
Context
()
self
.
targetPath
=
targetPath
if
context
:
self
.
zmqContextForCleaner
=
context
self
.
externalContext
=
True
else
:
self
.
zmqContextForCleaner
=
zmq
.
Context
()
self
.
externalContext
=
False
self
.
log
=
self
.
getLogger
()
self
.
log
.
debug
(
"
Init
"
)
...
...
@@ -91,6 +98,7 @@ class Cleaner():
if
workload
==
"
STOP
"
:
self
.
log
.
info
(
"
Stopping cleaner
"
)
self
.
stop
()
break
#transform to dictionary
try
:
...
...
@@ -224,5 +232,6 @@ class Cleaner():
def
stop
(
self
):
self
.
log
.
debug
(
"
Closing socket
"
)
self
.
zmqCleanerSocket
.
close
(
0
)
self
.
log
.
debug
(
"
Destroying context
"
)
self
.
zmqContextForCleaner
.
destroy
()
if
not
self
.
externalContext
:
self
.
log
.
debug
(
"
Destroying context
"
)
self
.
zmqContextForCleaner
.
destroy
()
This diff is collapsed.
Click to expand it.
src/ZeroMQTunnel/sender.py
+
18
−
7
View file @
251abb09
...
...
@@ -34,6 +34,7 @@ class WorkerProcess():
dataStreamIp
=
None
dataStreamPort
=
None
zmqContextForWorker
=
None
externalContext
=
None
# if the context was created outside this class or not
zmqMessageChunkSize
=
None
zmqCleanerIp
=
None
# responsable to delete/move files
zmqCleanerPort
=
None
# responsable to delete/move files
...
...
@@ -45,7 +46,7 @@ class WorkerProcess():
useLiveViewer
=
False
# boolian to inform if the receiver to show the files in the live viewer is running
# to get the logging only handling this class
log
=
None
log
=
None
def
__init__
(
self
,
id
,
dataStreamIp
,
dataStreamPort
,
chunkSize
,
zmqCleanerIp
,
zmqCleanerPort
,
context
=
None
):
...
...
@@ -57,7 +58,12 @@ class WorkerProcess():
self
.
zmqCleanerPort
=
zmqCleanerPort
#initialize router
self
.
zmqContextForWorker
=
context
or
zmq
.
Context
()
if
context
:
self
.
zmqContextForWorker
=
context
self
.
externalContext
=
True
else
:
self
.
zmqContextForWorker
=
zmq
.
Context
()
self
.
externalContext
=
False
self
.
log
=
self
.
getLogger
()
...
...
@@ -91,7 +97,7 @@ class WorkerProcess():
except
KeyboardInterrupt
:
# trace = traceback.format_exc()
self
.
log
.
debug
(
"
KeyboardInterrupt detected. Shutting down workerProcess
"
+
str
(
self
.
id
)
+
"
.
"
)
e
lse
:
e
xcept
:
trace
=
traceback
.
format_exc
()
self
.
log
.
error
(
"
Stopping workerProcess due to unknown error condition.
"
)
self
.
log
.
debug
(
"
Error was:
"
+
str
(
trace
))
...
...
@@ -184,9 +190,9 @@ class WorkerProcess():
#passing file to data-messagPipe
try
:
self
.
log
.
debug
(
"
worker-
"
+
str
(
id
)
+
"
: passing new file to data-messagePipe...
"
)
self
.
log
.
debug
(
"
worker-
"
+
str
(
self
.
id
)
+
"
: passing new file to data-messagePipe...
"
)
self
.
passFileToDataStream
(
filename
,
sourcePath
,
relativePath
)
self
.
log
.
debug
(
"
worker-
"
+
str
(
id
)
+
"
: passing new file to data-messagePipe...success.
"
)
self
.
log
.
debug
(
"
worker-
"
+
str
(
self
.
id
)
+
"
: passing new file to data-messagePipe...success.
"
)
except
Exception
,
e
:
errorMessage
=
"
Unable to pass new file to data-messagePipe.
"
self
.
log
.
error
(
errorMessage
)
...
...
@@ -301,6 +307,9 @@ class WorkerProcess():
# self.zmqDataStreamSocket.send_multipart(multipartMessage)
self
.
log
.
info
(
"
Passing multipart-message for file
"
+
str
(
sourceFilePathFull
)
+
"
...done.
"
)
except
zmq
.
error
.
Again
:
self
.
log
.
error
(
"
unable to send multiplart-message for file
"
+
str
(
sourceFilePathFull
))
self
.
log
.
error
(
"
Receiver has disconnected
"
).
except
Exception
,
e
:
self
.
log
.
error
(
"
Unable to send multipart-message for file
"
+
str
(
sourceFilePathFull
))
self
.
log
.
debug
(
"
Error was:
"
+
str
(
e
))
...
...
@@ -374,14 +383,16 @@ class WorkerProcess():
def
stop
(
self
):
self
.
log
.
debug
(
"
Sending stop signal to cleaner from worker
"
+
str
(
self
.
id
))
self
.
log
.
debug
(
"
Sending stop signal to cleaner from worker
-
"
+
str
(
self
.
id
))
self
.
cleanerSocket
.
send
(
"
STOP
"
)
self
.
log
.
info
(
"
Closing sockets for worker
"
+
str
(
self
.
id
))
if
self
.
zmqDataStreamSocket
:
self
.
zmqDataStreamSocket
.
close
(
0
)
self
.
routerSocket
.
close
(
0
)
self
.
cleanerSocket
.
close
(
0
)
self
.
zmqContextForWorker
.
destroy
()
if
not
self
.
externalContext
:
self
.
log
.
debug
(
"
Destroying context
"
)
self
.
zmqContextForWorker
.
destroy
()
...
...
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