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
35820587
Commit
35820587
authored
Nov 18, 2016
by
Rafael Monnerat
👻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial Work
parent
08b6c32d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
121 additions
and
1 deletion
+121
-1
product/CMFActivity/Activity/SQLJoblib.py
product/CMFActivity/Activity/SQLJoblib.py
+37
-0
product/CMFActivity/ActivityJoblibBackend.py
product/CMFActivity/ActivityJoblibBackend.py
+83
-0
product/CMFActivity/ActivityTool.py
product/CMFActivity/ActivityTool.py
+1
-1
No files found.
product/CMFActivity/Activity/SQLJoblib.py
0 → 100644
View file @
35820587
##############################################################################
#
# Copyright (c) 2002,2007 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
SQLQueue
import
SQLQueue
class
SQLJoblib
(
SQLQueue
):
"""
XXX SQLJoblib
"""
sql_table
=
'message_job'
uid_group
=
'portal_activity_job'
product/CMFActivity/ActivityJoblibBackend.py
0 → 100644
View file @
35820587
##############################################################################
#
# Copyright (c) 2016 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
ENABLE_JOBLIB
=
True
import
transaction
try
:
from
sklearn.externals.joblib.parallel
import
ParallelBackendBase
,
parallel_backend
except
ImportError
:
from
zLOG
import
LOG
,
WARNING
LOG
(
"CMFActivityBackend"
,
WARNING
,
"CLASS NOT LOADED!!!"
)
ENABLE_JOBLIB
=
False
class
CMFActivityResult
(
object
):
def
__init__
(
self
,
active_process
,
callback
):
self
.
active_process
=
active_process
self
.
callback
=
callback
def
get
(
self
,
timeout
=
None
):
while
not
self
.
active_process
.
getResultList
():
time
.
sleep
(
1
)
timeout
-=
1
if
timeout
<
0
:
raise
RuntimeError
(
'Timeout reached'
)
transaction
.
commit
()
result
=
self
.
active_process
.
getResultList
()[
0
].
result
if
self
.
callback
is
not
None
:
self
.
callback
(
result
)
return
result
if
ENABLE_JOBLIB
:
class
CMFActivityBackend
(
ParallelBackendBase
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
zope_context
=
kwargs
[
'zope_context'
]
def
effective_n_jobs
(
self
,
n_jobs
):
# TODO
return
n_jobs
def
apply_async
(
self
,
batch
,
callback
=
None
):
"""Schedule a func to be run"""
active_process
=
self
.
zope_context
.
portal_activities
.
newActiveProcess
()
active_process
.
batch
=
batch
active_process
.
activate
(
activity
=
'SQLQueue'
,
active_process
=
active_process
).
batch
()
transaction
.
commit
()
return
CMFActivityResult
(
active_process
,
callback
)
def
configure
(
self
,
n_jobs
=
1
,
parallel
=
None
,
**
backend_args
):
"""Reconfigure the backend and return the number of workers. This
makes it possible to reuse an existing backend instance for successive
independent calls to Parallel with different parameters."""
# TODO
self
.
parallel
=
parallel
# self.zope_context = backend_args['zope_context']
return
self
.
effective_n_jobs
(
n_jobs
)
else
:
class
CMFActivityBackend
(
object
):
pass
product/CMFActivity/ActivityTool.py
View file @
35820587
...
...
@@ -459,7 +459,7 @@ allow_class(GroupedMessage)
# Activity Registration
def
activity_dict
():
from
Activity
import
SQLDict
,
SQLQueue
from
Activity
import
SQLDict
,
SQLQueue
,
SQLJoblib
return
{
k
:
getattr
(
v
,
k
)()
for
k
,
v
in
locals
().
iteritems
()}
activity_dict
=
activity_dict
()
...
...
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