Skip to content

Commit

Permalink
Remove all 3.7 checks
Browse files Browse the repository at this point in the history
  • Loading branch information
gaogaotiantian committed Oct 3, 2023
1 parent dc38d05 commit 2979362
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 28 deletions.
6 changes: 1 addition & 5 deletions src/viztracer/code_monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ def visit_FunctionDef(self, node: ast.FunctionDef) -> ast.FunctionDef:
elif self.inst_type in ("log_var", "log_number"):
instrumented_nodes: List[ast.stmt] = []
args = node.args
if sys.version_info >= (3, 8):
func_args_name = [a.arg for a in args.posonlyargs + args.args + args.kwonlyargs]
else:
# python 3.7 does not have posonlyargs
func_args_name = [a.arg for a in args.args + args.kwonlyargs]
func_args_name = [a.arg for a in args.posonlyargs + args.args + args.kwonlyargs]
if "vararg" in args._fields and args.vararg:
func_args_name.append(args.vararg.arg)
if "kwarg" in args._fields and args.kwarg:
Expand Down
22 changes: 2 additions & 20 deletions src/viztracer/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def patch_spawned_process(viztracer_kwargs: Dict[str, Any], cmdline_args: List[s

@no_type_check
@functools.wraps(multiprocessing.spawn._main)
def _main_3839(fd, parent_sentinel) -> Any:
def _main(fd, parent_sentinel) -> Any:
with os.fdopen(fd, 'rb', closefd=True) as from_parent:
process.current_process()._inheriting = True
try:
Expand All @@ -174,25 +174,7 @@ def _main_3839(fd, parent_sentinel) -> Any:
del process.current_process()._inheriting
return self._bootstrap(parent_sentinel)

@no_type_check
@functools.wraps(multiprocessing.spawn._main)
def _main_3637(fd) -> Any:
with os.fdopen(fd, 'rb', closefd=True) as from_parent:
process.current_process()._inheriting = True
try:
preparation_data = reduction.pickle.load(from_parent)
prepare(preparation_data)
self: Process = reduction.pickle.load(from_parent)
sp = SpawnProcess(viztracer_kwargs, self.run, self._target, self._args, self._kwargs, cmdline_args)
self.run = sp.run
finally:
del process.current_process()._inheriting
return self._bootstrap()

if sys.version_info >= (3, 8):
multiprocessing.spawn._main = _main_3839 # type: ignore
else:
multiprocessing.spawn._main = _main_3637 # type: ignore
multiprocessing.spawn._main = _main # type: ignore


def install_all_hooks(
Expand Down
1 change: 0 additions & 1 deletion tests/test_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ def test_log_func_entry(self):
expected_output_file="result.json",
expected_entries=7)

@skipIf(sys.version_info < (3, 8), "sys.addaudithook does not exist on 3.8-")
def test_log_audit(self):
def check_func(include_names, exclude_names=[]):
def inner(data):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_multiprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def check_func(data):
self.template(["viztracer", "-o", "result.json", "cmdline_test.py"],
expected_output_file="result.json", script=file_fork, check_func=check_func)

@unittest.skipIf(sys.version_info < (3, 8) or sys.platform not in ["linux", "linux2"], "Only works on Linux + py3.8+")
@unittest.skipIf(sys.platform not in ["linux", "linux2"], "Only works on Linux")
def test_os_fork_term(self):
def check_func_wrapper(process_num):
def check_func(data):
Expand Down Expand Up @@ -408,7 +408,6 @@ def check_func(data):


class TestLoky(CmdlineTmpl):
@skipIf(sys.version_info < (3, 8), "fork + exec will make viztracer + loky deadlock")
def test_loky_basic(self):
def check_func(data):
pids = set()
Expand Down

0 comments on commit 2979362

Please sign in to comment.