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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Amer
erp5
Commits
f7a99a44
Commit
f7a99a44
authored
Sep 28, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Utils: prevent race condition on checkPythonSourceCode [WIP]
WIP: see problem in code comments. bug #20180928-1D89375
parent
99e67338
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
product/ERP5Type/Utils.py
product/ERP5Type/Utils.py
+16
-0
No files found.
product/ERP5Type/Utils.py
View file @
f7a99a44
...
...
@@ -44,6 +44,7 @@ from Acquisition import aq_base
from
Acquisition
import
aq_inner
from
Acquisition
import
aq_parent
from
Acquisition
import
aq_self
import
ZPublisher
from
AccessControl
import
ModuleSecurityInfo
from
AccessControl.SecurityInfo
import
allow_class
...
...
@@ -423,6 +424,8 @@ def fill_args_from_request(*optional_args):
_pylint_message_re
=
re
.
compile
(
'^(?P<type>[CRWEF]):
\
s*(?P<
r
ow>
\
d+),
\
s*(?P<column>
\
d+):
\
s*(?P<message>.*)$'
)
_pylint_lock
=
threading
.
Lock
()
def
checkPythonSourceCode
(
source_code_str
):
"""
Check source code with pylint or compile() builtin if not available.
...
...
@@ -464,9 +467,21 @@ def checkPythonSourceCode(source_code_str):
message_list
=
[]
output_file
=
cStringIO
.
StringIO
()
if
_pylint_lock
.
locked
():
# because this pylint integration temporarily replaces stdout
# with StringIO, we don't want this to run in parrallel.
# Also, rather than having the clients waiting in queue and accumulating
# several checks for what would probably be just an old version of the
# source code being edited, we prefer to raise an error.
# XXX - problem is when we save a component, there's an synchronous pylint
# happening and in this case (unlike the cases where we are "live checking"
# the code in an ajax request), we don't want user to get this error.
raise
ZPublisher
.
Retry
(
RuntimeError
(
"Pylint already running"
))
# pylint prints directly on stderr/stdout (only reporter content matters)
stderr
=
sys
.
stderr
stdout
=
sys
.
stdout
_pylint_lock
.
acquire
()
try
:
sys
.
stderr
=
cStringIO
.
StringIO
()
sys
.
stdout
=
cStringIO
.
StringIO
()
...
...
@@ -531,6 +546,7 @@ def checkPythonSourceCode(source_code_str):
output_file
.
close
()
sys
.
stderr
=
stderr
sys
.
stdout
=
stdout
_pylint_lock
.
release
()
#LOG('Utils', INFO, 'Checking time (pylint): %.2f' % (time.time() - started))
return
message_list
...
...
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