Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Hardik Juneja
erp5
Commits
4047fcc7
Commit
4047fcc7
authored
Dec 08, 2016
by
Loic Esteve
Committed by
Hardik Juneja
Oct 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move class definitions inside ENABLE_JOBLIB block
parent
88ad9ff6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
29 deletions
+29
-29
product/CMFActivity/ActivityJoblibBackend.py
product/CMFActivity/ActivityJoblibBackend.py
+29
-29
No files found.
product/CMFActivity/ActivityJoblibBackend.py
View file @
4047fcc7
...
@@ -43,38 +43,38 @@ except ImportError:
...
@@ -43,38 +43,38 @@ except ImportError:
LOG
(
"CMFActivityBackend"
,
WARNING
,
"CLASS NOT LOADED!!!"
)
LOG
(
"CMFActivityBackend"
,
WARNING
,
"CLASS NOT LOADED!!!"
)
ENABLE_JOBLIB
=
False
ENABLE_JOBLIB
=
False
class
MySafeFunction
(
SafeFunction
):
if
ENABLE_JOBLIB
:
"""Wrapper around a SafeFunction that catches any exception
class
MySafeFunction
(
SafeFunction
):
"""Wrapper around a SafeFunction that catches any exception
The exception can be handled in CMFActivityResult.get
The exception can be handled in CMFActivityResult.get
"""
"""
def
__call__
(
self
,
*
args
,
**
kwargs
):
def
__call__
(
self
,
*
args
,
**
kwargs
):
try
:
try
:
return
super
(
MySafeFunction
,
self
).
__call__
(
*
args
,
**
kwargs
)
return
super
(
MySafeFunction
,
self
).
__call__
(
*
args
,
**
kwargs
)
except
Exception
as
exc
:
except
Exception
as
exc
:
return
exc
return
exc
class
CMFActivityResult
(
object
):
class
CMFActivityResult
(
object
):
def
__init__
(
self
,
active_process
,
callback
):
def
__init__
(
self
,
active_process
,
callback
):
self
.
active_process
=
active_process
self
.
active_process
=
active_process
self
.
callback
=
callback
self
.
callback
=
callback
def
get
(
self
,
timeout
=
None
):
def
get
(
self
,
timeout
=
None
):
while
not
self
.
active_process
.
getResultList
():
while
not
self
.
active_process
.
getResultList
():
time
.
sleep
(
1
)
time
.
sleep
(
1
)
if
timeout
is
not
None
:
if
timeout
is
not
None
:
timeout
-=
1
timeout
-=
1
if
timeout
<
0
:
if
timeout
<
0
:
raise
RuntimeError
(
'Timeout reached'
)
raise
RuntimeError
(
'Timeout reached'
)
transaction
.
commit
()
transaction
.
commit
()
result
=
self
.
active_process
.
getResultList
()[
0
].
result
result
=
self
.
active_process
.
getResultList
()[
0
].
result
# TODO raise before or after the callback?
# TODO raise before or after the callback?
if
isinstance
(
result
,
Exception
):
if
isinstance
(
result
,
Exception
):
raise
result
raise
result
if
self
.
callback
is
not
None
:
if
self
.
callback
is
not
None
:
self
.
callback
(
result
)
self
.
callback
(
result
)
return
result
return
result
if
ENABLE_JOBLIB
:
class
CMFActivityBackend
(
ParallelBackendBase
):
class
CMFActivityBackend
(
ParallelBackendBase
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
zope_context
=
kwargs
[
'zope_context'
]
self
.
zope_context
=
kwargs
[
'zope_context'
]
...
...
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