Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Turris
ucollect
Commits
0c308f17
Unverified
Commit
0c308f17
authored
Jan 06, 2015
by
Michal 'vorner' Vaner
Browse files
Do the CPU-intensive work in different thread pool
And leave the rest for DB
parent
472f7dc6
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/master/buckets/batch.py
View file @
0c308f17
...
...
@@ -21,6 +21,7 @@ from twisted.internet.task import LoopingCall
from
twisted.internet
import
threads
,
reactor
from
twisted.python.failure
import
Failure
import
logging
import
plugin
logger
=
logging
.
getLogger
(
name
=
'buckets'
)
...
...
@@ -53,7 +54,7 @@ def flush():
global
__batch
if
__batch
:
logger
.
debug
(
"Batch flush"
)
deferred
=
threads
.
deferToThreadPool
(
reactor
,
reactor
.
getThreadP
ool
()
,
__execute
,
__batch
)
deferred
=
threads
.
deferToThreadPool
(
reactor
,
plugin
.
p
ool
,
__execute
,
__batch
)
deferred
.
addCallback
(
__distribute
)
__batch
=
[]
...
...
src/master/collect-master.py
View file @
0c308f17
...
...
@@ -26,13 +26,13 @@ import log_extra
import
logging
import
logging.handlers
from
client
import
ClientFactory
from
plugin
import
Plugins
from
plugin
import
Plugins
,
pool
import
master_config
import
activity
import
importlib
import
os
reactor
.
suggestThreadPoolSize
(
1
)
# Too much seems to have trouble with locking :-(
reactor
.
suggestThreadPoolSize
(
4
)
# Too much seems to have trouble with locking :-(
severity
=
master_config
.
get
(
'log_severity'
)
if
severity
==
'TRACE'
:
severity
=
log_extra
.
TRACE_LEVEL
...
...
@@ -91,6 +91,7 @@ logging.info('Init done')
reactor
.
run
()
logging
.
info
(
'Finishing up'
)
pool
.
stop
()
if
socat
:
soc
=
socat
socat
=
None
...
...
src/master/plugin.py
View file @
0c308f17
...
...
@@ -18,11 +18,16 @@
#
from
protocol
import
format_string
from
twisted.python.threadpool
import
ThreadPool
import
logging
import
time
logger
=
logging
.
getLogger
(
name
=
'plugin'
)
pool
=
ThreadPool
()
pool
.
adjustPoolsize
(
1
)
pool
.
start
()
class
Plugin
:
"""
Base class of a plugin. Use this when writing new plugins. Provides
...
...
Write
Preview
Supports
Markdown
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