Commit ec5d658f authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Move thread control to threaded commands

Refs: #4616, #4617

Remove max_theads from config, move control to threaded commands as --threads
Set default MAX_THREADS to 1
parent 515634db
...@@ -2,11 +2,13 @@ CHANGELOG for version 0.11 ...@@ -2,11 +2,13 @@ CHANGELOG for version 0.11
Bug Fixes: Bug Fixes:
-In file list, the path or prefix was converted to boolean value. Fixed. -In file list, the path or prefix was converted to boolean value. Fixed.
-Thread options did not work [#4616]
Changes: Changes:
1. Make astakosclient a mantatory requirement for kamaki [#4312] 1. Make astakosclient a mantatory requirement for kamaki [#4312]
2. Make post_user_catalogs obsolete, but keep for one more version [#4337] 2. Make post_user_catalogs obsolete, but keep for one more version [#4337]
3. Rename user commands for cached account requests as /user session [#4340] 3. Rename user commands for cached account requests as /user session [#4340]
4. Remove max_theads from config, move control to threaded commands [#4617]
Features: Features:
......
...@@ -312,7 +312,6 @@ def init_cached_authenticator(config_argument, cloud, logger): ...@@ -312,7 +312,6 @@ def init_cached_authenticator(config_argument, cloud, logger):
fake_cmd = _command_init(dict(config=config_argument)) fake_cmd = _command_init(dict(config=config_argument))
fake_cmd.client = auth_base fake_cmd.client = auth_base
fake_cmd._set_log_params() fake_cmd._set_log_params()
fake_cmd._update_max_threads()
tmp_base.authenticate(token) tmp_base.authenticate(token)
auth_base = tmp_base auth_base = tmp_base
except ClientError as ce: except ClientError as ce:
...@@ -558,6 +557,9 @@ def main(): ...@@ -558,6 +557,9 @@ def main():
if _debug: if _debug:
raise err raise err
exit(1) exit(1)
except KeyboardInterrupt:
print('Canceled by user')
exit(1)
except Exception as er: except Exception as er:
print('Unknown Error: %s' % er) print('Unknown Error: %s' % er)
if _debug: if _debug:
......
...@@ -57,7 +57,6 @@ def addLogSettings(foo): ...@@ -57,7 +57,6 @@ def addLogSettings(foo):
return foo(self, *args, **kwargs) return foo(self, *args, **kwargs)
finally: finally:
self._set_log_params() self._set_log_params()
self._update_max_threads
return wrap return wrap
...@@ -171,12 +170,6 @@ class _command_init(object): ...@@ -171,12 +170,6 @@ class _command_init(object):
log.debug('Failed to read custom log_pid setting:' log.debug('Failed to read custom log_pid setting:'
'%s\n default for log_pid is off' % e) '%s\n default for log_pid is off' % e)
def _update_max_threads(self):
if getattr(self, 'client', None):
max_threads = int(self['config'].get('global', 'max_threads'))
assert max_threads > 0, 'invalid max_threads config option'
self.client.MAX_THREADS = max_threads
def _safe_progress_bar( def _safe_progress_bar(
self, msg, arg='progress_bar', countdown=False, timeout=100): self, msg, arg='progress_bar', countdown=False, timeout=100):
"""Try to get a progress bar, but do not raise errors""" """Try to get a progress bar, but do not raise errors"""
......
...@@ -387,7 +387,9 @@ class server_create(_init_cyclades, _optional_json, _server_wait): ...@@ -387,7 +387,9 @@ class server_create(_init_cyclades, _optional_json, _server_wait):
'Create a cluster of servers of this size. In this case, the name' 'Create a cluster of servers of this size. In this case, the name'
'parameter is the prefix of each server in the cluster (e.g.,' 'parameter is the prefix of each server in the cluster (e.g.,'
'srv1, srv2, etc.', 'srv1, srv2, etc.',
'--cluster-size') '--cluster-size'),
max_threads=IntArgument(
'Max threads in cluster mode (default 1)', '--threads')
) )
@errors.cyclades.cluster_size @errors.cyclades.cluster_size
...@@ -399,6 +401,7 @@ class server_create(_init_cyclades, _optional_json, _server_wait): ...@@ -399,6 +401,7 @@ class server_create(_init_cyclades, _optional_json, _server_wait):
personality=self['personality']) for i in range(1, 1 + size)] personality=self['personality']) for i in range(1, 1 + size)]
if size == 1: if size == 1:
return [self.client.create_server(**servers[0])] return [self.client.create_server(**servers[0])]
self.client.MAX_THREADS = int(self['max_threads'] or 1)
try: try:
r = self.client.async_run(self.client.create_server, servers) r = self.client.async_run(self.client.create_server, servers)
return r return r
......
...@@ -1045,7 +1045,7 @@ class file_upload(_file_container_command, _optional_output_cmd): ...@@ -1045,7 +1045,7 @@ class file_upload(_file_container_command, _optional_output_cmd):
'( "read=user1,grp1,user2,... write=user1,grp2,... )']), '( "read=user1,grp1,user2,... write=user1,grp2,... )']),
parsed_name='--sharing'), parsed_name='--sharing'),
public=FlagArgument('make object publicly accessible', '--public'), public=FlagArgument('make object publicly accessible', '--public'),
poolsize=IntArgument('set pool size', '--with-pool-size'), max_threads=IntArgument('set max threads (default 5)', '--threads'),
progress_bar=ProgressBarArgument( progress_bar=ProgressBarArgument(
'do not show progress bar', 'do not show progress bar',
('-N', '--no-progress-bar'), ('-N', '--no-progress-bar'),
...@@ -1152,8 +1152,7 @@ class file_upload(_file_container_command, _optional_output_cmd): ...@@ -1152,8 +1152,7 @@ class file_upload(_file_container_command, _optional_output_cmd):
@errors.pithos.object_path @errors.pithos.object_path
@errors.pithos.local_path @errors.pithos.local_path
def _run(self, local_path, remote_path): def _run(self, local_path, remote_path):
if self['poolsize'] > 0: self.client.MAX_THREADS = int(self['max_threads'] or 5)
self.client.MAX_THREADS = int(self['poolsize'])
params = dict( params = dict(
content_encoding=self['content_encoding'], content_encoding=self['content_encoding'],
content_type=self['content_type'], content_type=self['content_type'],
...@@ -1272,7 +1271,7 @@ class file_download(_file_container_command): ...@@ -1272,7 +1271,7 @@ class file_download(_file_container_command):
'show output unmodified since then', '--if-unmodified-since'), 'show output unmodified since then', '--if-unmodified-since'),
object_version=ValueArgument( object_version=ValueArgument(
'get the specific version', ('-O', '--object-version')), 'get the specific version', ('-O', '--object-version')),
poolsize=IntArgument('set pool size', '--with-pool-size'), max_threads=IntArgument('set max threads (default 5)', '--threads'),
progress_bar=ProgressBarArgument( progress_bar=ProgressBarArgument(
'do not show progress bar', ('-N', '--no-progress-bar'), 'do not show progress bar', ('-N', '--no-progress-bar'),
default=False), default=False),
...@@ -1389,9 +1388,7 @@ class file_download(_file_container_command): ...@@ -1389,9 +1388,7 @@ class file_download(_file_container_command):
@errors.pithos.object_path @errors.pithos.object_path
@errors.pithos.local_path @errors.pithos.local_path
def _run(self, local_path): def _run(self, local_path):
poolsize = self['poolsize'] self.client.MAX_THREADS = int(self['max_threads'] or 5)
if poolsize:
self.client.MAX_THREADS = int(poolsize)
progress_bar = None progress_bar = None
try: try:
for f, rpath in self._outputs(local_path): for f, rpath in self._outputs(local_path):
......
...@@ -77,7 +77,6 @@ DEFAULTS = { ...@@ -77,7 +77,6 @@ DEFAULTS = {
'log_token': 'off', 'log_token': 'off',
'log_data': 'off', 'log_data': 'off',
'log_pid': 'off', 'log_pid': 'off',
'max_threads': 7,
'history_file': HISTORY_PATH, 'history_file': HISTORY_PATH,
'user_cli': 'astakos', 'user_cli': 'astakos',
'admin_cli': 'astakos', 'admin_cli': 'astakos',
......
...@@ -68,7 +68,6 @@ class Config(TestCase): ...@@ -68,7 +68,6 @@ class Config(TestCase):
self.config_file_content = [ self.config_file_content = [
HEADER, HEADER,
'[global]\n', '[global]\n',
'max_threads = 5\n',
'default_cloud = ~mycloud\n', 'default_cloud = ~mycloud\n',
'file_cli = pithos\n', 'file_cli = pithos\n',
'history_file = /home/user/.kamaki.history\n', 'history_file = /home/user/.kamaki.history\n',
......
...@@ -331,7 +331,7 @@ class SilentEvent(Thread): ...@@ -331,7 +331,7 @@ class SilentEvent(Thread):
class Client(Logged): class Client(Logged):
MAX_THREADS = 7 MAX_THREADS = 1
DATE_FORMATS = ['%a %b %d %H:%M:%S %Y', ] DATE_FORMATS = ['%a %b %d %H:%M:%S %Y', ]
CONNECTION_RETRY_LIMIT = 0 CONNECTION_RETRY_LIMIT = 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment