zoukankan      html  css  js  c++  java
  • python3下tomorow模块 @thread报语法错误def async(n, base_type, timeout=None): ^ SyntaxError: invalid syntax---解决方法

    遇见问题:python使用tomorrow实现多线程,tomorrow模块的源代码报语法错误?

    这是报错信息:
    Traceback (most recent call last):
      File "C:/programmer/boyuncar900_v1/main.py", line 5, in <module>
        from tomorrow import threads
      File "C:programmerpythonlibsite-packages omorrow_init_.py", line 1, in <module>
        from .tomorrow import threads
      File "C:programmerpythonlibsite-packages omorrow omorrow.py", line 20
        def async(n, base_type, timeout=None):
                ^
    SyntaxError: invalid syntax

    解决办法:async是python关键字,源代码换个函数名,比如async_tm。

    from tomorrow import threads
    
    
    def add_case(case_path=casepath, rule="test*.py"):
    
        pass
    
    @threads(5)
    def run_case(all_case, report_path=reportpath, nth=0):
    
        '''执行所有的用例, 并把结果写入测试报告'''
    
        pass

     

    解决办法:async是python关键字,源代码换个函数名,比如async_tm。

    def async_mc(n, base_type, timeout=None):
        def decorator(f):
            if isinstance(n, int):
                pool = base_type(n)
            elif isinstance(n, base_type):
                pool = n
            else:
                raise TypeError(
                    "Invalid type: %s"
                    % type(base_type)
                )
            @wraps(f)
            def wrapped(*args, **kwargs):
                return Tomorrow(
                    pool.submit(f, *args, **kwargs),
                    timeout=timeout
                )
            return wrapped
        return decorator
    
    
    def threads(n, timeout=None):
        return async_mc(n, ThreadPoolExecutor, timeout)
  • 相关阅读:
    SSRS_NOTE
    github快速使用指南
    Serving 404s instead of errors solved :)
    如何提高LINQtoSQL延时加载的性能
    SqlServer开发利器—SQL Prompt5
    内核通知链 学习笔记 arm
    Excel报表之js版
    JS修改Table中Td的值。
    什么时候能忙完~
    JS修改Table中Td的值(修改)
  • 原文地址:https://www.cnblogs.com/xyao1/p/10912881.html
Copyright © 2011-2022 走看看