mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of gitlab.com:bashrc2/epicyon
commit
d4e82fef0a
|
@ -355,6 +355,7 @@ def replace_emoji_from_tags(session, base_dir: str,
|
||||||
replace_char)
|
replace_char)
|
||||||
replaced = True
|
replaced = True
|
||||||
except BaseException:
|
except BaseException:
|
||||||
|
if debug:
|
||||||
print('EX: replace_emoji_from_tags 1 ' +
|
print('EX: replace_emoji_from_tags 1 ' +
|
||||||
'no conversion of ' +
|
'no conversion of ' +
|
||||||
str(icon_name) + ' to chr ' +
|
str(icon_name) + ' to chr ' +
|
||||||
|
@ -377,7 +378,9 @@ def replace_emoji_from_tags(session, base_dir: str,
|
||||||
replaced = True
|
replaced = True
|
||||||
except BaseException:
|
except BaseException:
|
||||||
icon_code_sequence = ''
|
icon_code_sequence = ''
|
||||||
print('EX: replace_emoji_from_tags 2 ' +
|
if debug:
|
||||||
|
print('EX: ' +
|
||||||
|
'replace_emoji_from_tags 2 ' +
|
||||||
'no conversion of ' +
|
'no conversion of ' +
|
||||||
str(icode) + ' to chr ' +
|
str(icode) + ' to chr ' +
|
||||||
tag_item['name'] + ' ' +
|
tag_item['name'] + ' ' +
|
||||||
|
|
|
@ -21111,12 +21111,15 @@ def run_daemon(check_actor_timeout: int,
|
||||||
args=(base_dir, httpd.fitness), daemon=True)
|
args=(base_dir, httpd.fitness), daemon=True)
|
||||||
httpd.thrFitness.start()
|
httpd.thrFitness.start()
|
||||||
|
|
||||||
|
httpd.recent_posts_cache = {}
|
||||||
|
|
||||||
print('THREAD: Creating cache expiry thread')
|
print('THREAD: Creating cache expiry thread')
|
||||||
httpd.thrCache = \
|
httpd.thrCache = \
|
||||||
thread_with_trace(target=expire_cache,
|
thread_with_trace(target=expire_cache,
|
||||||
args=(base_dir, httpd.person_cache,
|
args=(base_dir, httpd.person_cache,
|
||||||
httpd.http_prefix,
|
httpd.http_prefix,
|
||||||
archive_dir,
|
archive_dir,
|
||||||
|
httpd.recent_posts_cache,
|
||||||
httpd.maxPostsInBox), daemon=True)
|
httpd.maxPostsInBox), daemon=True)
|
||||||
httpd.thrCache.start()
|
httpd.thrCache.start()
|
||||||
|
|
||||||
|
@ -21150,7 +21153,6 @@ def run_daemon(check_actor_timeout: int,
|
||||||
else:
|
else:
|
||||||
httpd.thrSharesExpire.start()
|
httpd.thrSharesExpire.start()
|
||||||
|
|
||||||
httpd.recent_posts_cache = {}
|
|
||||||
httpd.max_recent_posts = max_recent_posts
|
httpd.max_recent_posts = max_recent_posts
|
||||||
httpd.iconsCache = {}
|
httpd.iconsCache = {}
|
||||||
httpd.fontsCache = {}
|
httpd.fontsCache = {}
|
||||||
|
|
2
posts.py
2
posts.py
|
@ -4118,7 +4118,7 @@ def _create_box_indexed(recent_posts_cache: {},
|
||||||
def expire_cache(base_dir: str, person_cache: {},
|
def expire_cache(base_dir: str, person_cache: {},
|
||||||
http_prefix: str, archive_dir: str,
|
http_prefix: str, archive_dir: str,
|
||||||
recent_posts_cache: {},
|
recent_posts_cache: {},
|
||||||
max_posts_in_box=32000):
|
max_posts_in_box: int):
|
||||||
"""Thread used to expire actors from the cache and archive old posts
|
"""Thread used to expire actors from the cache and archive old posts
|
||||||
"""
|
"""
|
||||||
while True:
|
while True:
|
||||||
|
|
121
tests.py
121
tests.py
|
@ -678,7 +678,7 @@ def _test_cache():
|
||||||
assert result['test'] == 'This is a test'
|
assert result['test'] == 'This is a test'
|
||||||
|
|
||||||
|
|
||||||
def _test_threads_function(param: str):
|
def _test_threads_function(param1: str, param2: str):
|
||||||
for _ in range(10000):
|
for _ in range(10000):
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
|
@ -687,7 +687,7 @@ def _test_threads():
|
||||||
print('test_threads')
|
print('test_threads')
|
||||||
thr = \
|
thr = \
|
||||||
thread_with_trace(target=_test_threads_function,
|
thread_with_trace(target=_test_threads_function,
|
||||||
args=('test',),
|
args=('test', 'test2'),
|
||||||
daemon=True)
|
daemon=True)
|
||||||
thr.start()
|
thr.start()
|
||||||
assert thr.is_alive() is True
|
assert thr.is_alive() is True
|
||||||
|
@ -4869,6 +4869,122 @@ def _test_post_field_names(source_file: str, fieldnames: []):
|
||||||
assert False
|
assert False
|
||||||
|
|
||||||
|
|
||||||
|
def _test_thread_functions():
|
||||||
|
print('test_thread_functions')
|
||||||
|
modules = {}
|
||||||
|
threads_called_in_modules = []
|
||||||
|
|
||||||
|
# get the source for each module
|
||||||
|
for _, _, files in os.walk('.'):
|
||||||
|
for source_file in files:
|
||||||
|
if not source_file.endswith('.py'):
|
||||||
|
continue
|
||||||
|
if source_file.startswith('.#'):
|
||||||
|
continue
|
||||||
|
if source_file.startswith('flycheck_'):
|
||||||
|
continue
|
||||||
|
mod_name = source_file.replace('.py', '')
|
||||||
|
if mod_name == 'threads':
|
||||||
|
# don't test the threads module itself
|
||||||
|
continue
|
||||||
|
modules[mod_name] = {
|
||||||
|
'functions': []
|
||||||
|
}
|
||||||
|
source_str = ''
|
||||||
|
with open(source_file, 'r') as fp_src:
|
||||||
|
source_str = fp_src.read()
|
||||||
|
modules[mod_name]['source'] = source_str
|
||||||
|
if 'thread_with_trace(' in source_str:
|
||||||
|
threads_called_in_modules.append(mod_name)
|
||||||
|
with open(source_file, 'r') as fp_src:
|
||||||
|
lines = fp_src.readlines()
|
||||||
|
modules[mod_name]['lines'] = lines
|
||||||
|
|
||||||
|
for mod_name in threads_called_in_modules:
|
||||||
|
thread_sections = \
|
||||||
|
modules[mod_name]['source'].split('thread_with_trace(')
|
||||||
|
ctr = 0
|
||||||
|
for thread_str in thread_sections:
|
||||||
|
if ctr == 0 or ',' not in thread_str:
|
||||||
|
ctr += 1
|
||||||
|
continue
|
||||||
|
thread_function_args = thread_str.split(',')
|
||||||
|
first_parameter = thread_function_args[0]
|
||||||
|
if 'target=' not in first_parameter:
|
||||||
|
ctr += 1
|
||||||
|
continue
|
||||||
|
thread_function_name = first_parameter.split('target=')[1].strip()
|
||||||
|
if not thread_function_name:
|
||||||
|
ctr += 1
|
||||||
|
continue
|
||||||
|
if thread_function_name.startswith('self.'):
|
||||||
|
thread_function_name = thread_function_name.split('self.')[1]
|
||||||
|
# is this function declared at the top of the module
|
||||||
|
# or defined within the module?
|
||||||
|
import_str = ' import ' + thread_function_name
|
||||||
|
def_str = 'def ' + thread_function_name + '('
|
||||||
|
if import_str not in modules[mod_name]['source']:
|
||||||
|
if def_str not in modules[mod_name]['source']:
|
||||||
|
print(mod_name + ' ' + first_parameter)
|
||||||
|
print(import_str + ' not in ' + mod_name)
|
||||||
|
assert(False)
|
||||||
|
if def_str in modules[mod_name]['source']:
|
||||||
|
defininition_module = mod_name
|
||||||
|
else:
|
||||||
|
# which module is the thread function defined within?
|
||||||
|
test_str = modules[mod_name]['source'].split(import_str)[0]
|
||||||
|
defininition_module = test_str.split('from ')[-1]
|
||||||
|
print('Thread function ' + thread_function_name +
|
||||||
|
' defined in ' + defininition_module)
|
||||||
|
# check the function arguments
|
||||||
|
second_parameter = thread_function_args[1]
|
||||||
|
if 'args=' not in second_parameter:
|
||||||
|
print('No args parameter in ' + thread_function_name +
|
||||||
|
' module ' + mod_name)
|
||||||
|
ctr += 1
|
||||||
|
continue
|
||||||
|
arg_ctr = 0
|
||||||
|
calling_function_args_list = []
|
||||||
|
for func_arg in thread_function_args:
|
||||||
|
if arg_ctr == 0:
|
||||||
|
arg_ctr += 1
|
||||||
|
continue
|
||||||
|
last_arg = False
|
||||||
|
if '(' in func_arg and '()' not in func_arg:
|
||||||
|
func_arg = func_arg.split('(')[1]
|
||||||
|
|
||||||
|
if func_arg.endswith(')') and '()' not in func_arg:
|
||||||
|
func_arg = func_arg.split(')')[0]
|
||||||
|
last_arg = True
|
||||||
|
func_arg = func_arg.strip()
|
||||||
|
calling_function_args_list.append(func_arg)
|
||||||
|
if last_arg:
|
||||||
|
break
|
||||||
|
arg_ctr += 1
|
||||||
|
# print(mod_name + ' ' + thread_function_name + ' ' +
|
||||||
|
# str(calling_function_args_list))
|
||||||
|
# get the function definition arguments
|
||||||
|
test_str = \
|
||||||
|
modules[defininition_module]['source'].split(def_str)[1]
|
||||||
|
test_str = test_str.split(')')[0]
|
||||||
|
definition_function_args_list = test_str.split(',')
|
||||||
|
if len(definition_function_args_list) > 0:
|
||||||
|
if definition_function_args_list[0] == 'self':
|
||||||
|
definition_function_args_list = \
|
||||||
|
definition_function_args_list[1:]
|
||||||
|
if len(definition_function_args_list) != \
|
||||||
|
len(calling_function_args_list):
|
||||||
|
print('Thread function ' + thread_function_name +
|
||||||
|
' has ' + str(len(definition_function_args_list)) +
|
||||||
|
' arguments, but ' +
|
||||||
|
str(len(calling_function_args_list)) +
|
||||||
|
' were given in module ' + mod_name)
|
||||||
|
print(str(definition_function_args_list))
|
||||||
|
print(str(calling_function_args_list))
|
||||||
|
assert(False)
|
||||||
|
ctr += 1
|
||||||
|
|
||||||
|
|
||||||
def _test_functions():
|
def _test_functions():
|
||||||
print('test_functions')
|
print('test_functions')
|
||||||
function = {}
|
function = {}
|
||||||
|
@ -6779,6 +6895,7 @@ def run_all_tests():
|
||||||
['queue_json', 'post_json_object',
|
['queue_json', 'post_json_object',
|
||||||
'message_json', 'liked_post_json'])
|
'message_json', 'liked_post_json'])
|
||||||
_test_checkbox_names()
|
_test_checkbox_names()
|
||||||
|
_test_thread_functions()
|
||||||
_test_functions()
|
_test_functions()
|
||||||
_test_bold_reading()
|
_test_bold_reading()
|
||||||
_test_published_to_local_timezone()
|
_test_published_to_local_timezone()
|
||||||
|
|
Loading…
Reference in New Issue