当前位置: 首页>>代码示例>>Python>>正文


Python threading.html方法代码示例

本文整理汇总了Python中threading.html方法的典型用法代码示例。如果您正苦于以下问题:Python threading.html方法的具体用法?Python threading.html怎么用?Python threading.html使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在threading的用法示例。


在下文中一共展示了threading.html方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import threading [as 别名]
# 或者: from threading import html [as 别名]
def __init__(self):
        # A Barrier is a synchronisation primitive which allows a fixed number
        # of threads (in our case, 2) to wait for each other. We use it here
        # to demonstrate that testcases are run concurrently and how they may
        # be synchronised with each other.
        #
        # Note that on Python 3 you can use the Barrier class from the standard
        # library:
        # https://docs.python.org/3.7/library/threading.html#barrier-objects .
        # Here we use a backported Barrier provided by Testplan, which works
        # on both Python 2 and 3.
        self._barrier = thread_utils.Barrier(2)

        # The Event synchronisation primitive allows one thread to signal to
        # another that is waiting on the first thread to do some work. We use
        # it here to demonstrate another way testcases within the same
        # execution group may be synchronised with each other.
        self._test_g2_1_done = threading.Event() 
开发者ID:Morgan-Stanley,项目名称:testplan,代码行数:20,代码来源:parallel_tasks.py

示例2: open_hdf

# 需要导入模块: import threading [as 别名]
# 或者: from threading import html [as 别名]
def open_hdf(self, mode='r+'):
        """
        Opens the hdf5 file.

        This should be called at the start of every method that access the h5 file
        and :meth:`~.Subject.close_hdf` should be called at the end. Otherwise
        the file will close and we risk file corruption.

        See the pytables docs
        `here <https://www.pytables.org/cookbook/threading.html>`_ and
        `here <https://www.pytables.org/FAQ.html#can-pytables-be-used-in-concurrent-access-scenarios>`_

        Args:
            mode (str): a file access mode, can be:

                * 'r': Read-only - no data can be modified.
                * 'w': Write - a new file is created (an existing file with the same name would be deleted).
                * 'a' Append - an existing file is opened for reading and writing, and if the file does not exist it is created.
                * 'r+' (default) - Similar to 'a', but file must already exist.

        Returns:
            :class:`tables.File`: Opened hdf file.
        """
        # TODO: Use a decorator around methods instead of explicitly calling
        with self.lock:
            return tables.open_file(self.file, mode=mode) 
开发者ID:wehr-lab,项目名称:autopilot,代码行数:28,代码来源:subject.py

示例3: install

# 需要导入模块: import threading [as 别名]
# 或者: from threading import html [as 别名]
def install(
        builtins=True,
        snoop="snoop",
        pp="pp",
        spy="spy",
        out=None,
        prefix='',
        columns='time',
        overwrite=False,
        color=None,
        enabled=True,
        watch_extras=(),
        replace_watch_extras=None,
        formatter_class=DefaultFormatter,
):
    """
    Configure output, enable or disable, and add names to builtins. Parameters:
    
    - builtins: set to False to not add any names to builtins,
        so importing will still be required.
    - snoop, pp, and spy: set to other strings 
        to choose the names of these functions in builtins
    - `out`: determines the output destination. By default this is stderr. You can also pass:
        - A string or a `Path` object to write to a file at that location. By default this always will append to the file. Pass `overwrite=True` to clear the file initially.
        - Anything with a `write` method, e.g. `sys.stdout` or a file object.
        - Any callable with a single string argument, e.g. `logger.info`.
    - `color`: determines whether the output includes escape characters to display colored text in the console. If you see weird characters in your output, your console doesn't support colors, so pass `color=False`.
        - Code is syntax highlighted using [Pygments](http://pygments.org/), and this argument is passed as the style. You can choose a different color scheme by passing a string naming a style (see [this gallery](https://help.farbox.com/pygments.html)) or a style class. The default style is monokai.   
        - By default this parameter is set to `out.isatty()`, which is usually true for stdout and stderr but will be false if they are redirected or piped. Pass `True` or a style if you want to force coloring.
        - To see colors in the PyCharm Run window, edit the Run Configuration and tick "Emulate terminal in output console".
    - `prefix`: Pass a string to start all snoop lines with that string so you can grep for them easily.
    - `columns`: This specifies the columns at the start of each output line. You can pass a string with the names of built in columns separated by spaces or commas. These are the available columns:
        - `time`: The current time. This is the only column by default.
        - `thread`: The name of the current thread.  
        - `thread_ident`: The [identifier](https://docs.python.org/3/library/threading.html#threading.Thread.ident) of the current thread, in case thread names are not unique.
        - `file`: The filename (not the full path) of the current function.
        - `full_file`: The full path to the file (also shown anyway when the function is called).
        - `function`: The name of the current function.
        - `function_qualname`: The qualified name of the current function.
        
        If you want a custom column, please open an issue to tell me what you're interested in! In the meantime, you can pass a list, where the elements are either strings or callables. The callables should take one argument, which will be an `Event` object. It has attributes `frame`, `event`, and `arg`, as specified in [`sys.settrace()`](https://docs.python.org/3/library/sys.html#sys.settrace), and other attributes which may change. 
    """
    
    if builtins:
        setattr(builtins_module, snoop, package.snoop)
        setattr(builtins_module, pp, package.pp)
        setattr(builtins_module, spy, package.spy)
    config = Config(
        out=out,
        prefix=prefix,
        columns=columns,
        overwrite=overwrite,
        color=color,
        enabled=enabled,
        watch_extras=watch_extras,
        replace_watch_extras=replace_watch_extras,
        formatter_class=formatter_class,
    )
    package.snoop.config = config
    package.pp.config = config
    package.spy.config = config 
开发者ID:alexmojaki,项目名称:snoop,代码行数:63,代码来源:configuration.py

示例4: new_subject_file

# 需要导入模块: import threading [as 别名]
# 或者: from threading import html [as 别名]
def new_subject_file(self, biography):
        """
        Create a new subject file and make the general filestructure.

        If a file already exists, open it in append mode, otherwise create it.

        Args:
            biography (dict): Biographical details like DOB, mass, etc.
                Typically created by :class:`~.gui.New_Subject_Wizard.Biography_Tab`.
        """
        # If a file already exists, we open it for appending so we don't lose data.
        # For now we are assuming that the existing file has the basic structure,
        # but that's probably a bad assumption for full reliability
        if os.path.isfile(self.file):
            h5f = self.open_hdf(mode='a')
        else:
            h5f = self.open_hdf(mode='w')

            # Make Basic file structure
            h5f.create_group("/","data","Trial Record Data")
            h5f.create_group("/","info","Biographical Info")
            history_group = h5f.create_group("/","history","History")

            # When a whole protocol is changed, we stash the old protocol as a filenode in the past_protocols group
            h5f.create_group("/history", "past_protocols",'Past Protocol Files')

            # Also canonical to the basic file structure is the 'current' filenode which stores the current protocol,
            # but since we want to be able to tell that a protocol hasn't been assigned yet we don't instantiate it here
            # See http://www.pytables.org/usersguide/filenode.html
            # filenode.new_node(h5f, where="/", name="current")

            # We keep track of changes to parameters, promotions, etc. in the history table
            h5f.create_table(history_group, 'history', self.History_Table, "Change History")

            # Make table for weights
            h5f.create_table(history_group, 'weights', self.Weight_Table, "Subject Weights")

            # And another table to stash the git hash every time we're open.
            h5f.create_table(history_group, 'hashes', self.Hash_Table, "Git commit hash history")

        # Save biographical information as node attributes
        if biography:
            for k, v in biography.items():
                h5f.root.info._v_attrs[k] = v

        h5f.root.info._v_attrs['name'] = self.name

        self.close_hdf(h5f) 
开发者ID:wehr-lab,项目名称:autopilot,代码行数:50,代码来源:subject.py


注:本文中的threading.html方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。