golden hour
/opt/saltstack/salt/lib/python3.10/site-packages/salt/ext/tornado/__pycache__
⬆️ Go Up
Upload
File/Folder
Size
Actions
__init__.cpython-310.pyc
378 B
Del
OK
_locale_data.cpython-310.pyc
3.23 KB
Del
OK
auth.cpython-310.pyc
39.18 KB
Del
OK
autoreload.cpython-310.pyc
7.02 KB
Del
OK
concurrent.cpython-310.pyc
17.24 KB
Del
OK
curl_httpclient.cpython-310.pyc
12.8 KB
Del
OK
escape.cpython-310.pyc
9.89 KB
Del
OK
gen.cpython-310.pyc
38.39 KB
Del
OK
http1connection.cpython-310.pyc
19.47 KB
Del
OK
httpclient.cpython-310.pyc
25.19 KB
Del
OK
httpserver.cpython-310.pyc
11.45 KB
Del
OK
httputil.cpython-310.pyc
29.84 KB
Del
OK
ioloop.cpython-310.pyc
33.19 KB
Del
OK
iostream.cpython-310.pyc
42.97 KB
Del
OK
locale.cpython-310.pyc
15.22 KB
Del
OK
locks.cpython-310.pyc
16.61 KB
Del
OK
log.cpython-310.pyc
8.07 KB
Del
OK
netutil.cpython-310.pyc
14.32 KB
Del
OK
options.cpython-310.pyc
19.63 KB
Del
OK
process.cpython-310.pyc
10.27 KB
Del
OK
queues.cpython-310.pyc
11.29 KB
Del
OK
routing.cpython-310.pyc
21.08 KB
Del
OK
simple_httpclient.cpython-310.pyc
16.08 KB
Del
OK
stack_context.cpython-310.pyc
10.65 KB
Del
OK
tcpclient.cpython-310.pyc
6.49 KB
Del
OK
tcpserver.cpython-310.pyc
10.06 KB
Del
OK
template.cpython-310.pyc
30.52 KB
Del
OK
testing.cpython-310.pyc
24.61 KB
Del
OK
util.cpython-310.pyc
13.72 KB
Del
OK
web.cpython-310.pyc
105.22 KB
Del
OK
websocket.cpython-310.pyc
39.08 KB
Del
OK
wsgi.cpython-310.pyc
11.5 KB
Del
OK
Edit: concurrent.cpython-310.pyc
o �xeJ � @ s^ d Z ddlmZmZmZ ddlZddlZddlZddlZddl Z ddl mZ ddlm Z mZ ddlmZmZmZ zddlmZ W n eyK dZY nw zddlZW n ey] dZY nw e�� dkohejd kZG d d� de�ZG dd � d e�ZG dd� de�ZeZedu r�eZ nejefZ dd� Z!G dd� de�Z"e"� Z#dd� Z$e� Z%dd� Z&dd� Z'dS )a[ Utilities for working with threads and ``Futures``. ``Futures`` are a pattern for concurrent programming introduced in Python 3.2 in the `concurrent.futures` package. This package defines a mostly-compatible `Future` class designed for use from coroutines, as well as some utility functions for interacting with the `concurrent.futures` package. � )�absolute_import�division�print_functionN)�app_log)�ExceptionStackContext�wrap)�ArgReplacer� is_finalizing�raise_exc_info)�futures�CPython)� � c @ s e Zd ZdS )�ReturnValueIgnoredErrorN)�__name__� __module__�__qualname__� r r �O/opt/saltstack/salt/lib/python3.10/site-packages/salt/ext/tornado/concurrent.pyr 8 s r c @ s8 e Zd ZdZdZdd� Zdd� Zdd� Zefd d �Z dS )�_TracebackLoggera Helper to log a traceback upon destruction if not cleared. This solves a nasty problem with Futures and Tasks that have an exception set: if nobody asks for the exception, the exception is never logged. This violates the Zen of Python: 'Errors should never pass silently. Unless explicitly silenced.' However, we don't want to log the exception as soon as set_exception() is called: if the calling code is written properly, it will get the exception and handle it properly. But we *do* want to log it if result() or exception() was never called -- otherwise developers waste a lot of time wondering why their buggy code fails silently. An earlier attempt added a __del__() method to the Future class itself, but this backfired because the presence of __del__() prevents garbage collection from breaking cycles. A way out of this catch-22 is to avoid having a __del__() method on the Future class itself, but instead to have a reference to a helper object with a __del__() method that logs the traceback, where we ensure that the helper object doesn't participate in cycles, and only the Future has a reference to it. The helper object is added when set_exception() is called. When the Future is collected, and the helper is present, the helper object is also collected, and its __del__() method will log the traceback. When the Future's result() or exception() method is called (and a helper object is present), it removes the helper object, after calling its clear() method to prevent it from logging. One downside is that we do a fair amount of work to extract the traceback from the exception, even when it is never logged. It would seem cheaper to just store the exception object, but that references the traceback, which references stack frames, which may reference the Future, which references the _TracebackLogger, and then the _TracebackLogger would be included in a cycle, which is what we're trying to avoid! As an optimization, we don't immediately format the exception; we only do the work when activate() is called, which call is delayed until after all the Future's callbacks have run. Since usually a Future has at least one callback (typically set by 'yield From') and usually that callback extracts the callback, thereby removing the need to format the exception. PS. I don't claim credit for this solution. I first heard of it in a discussion about closing files when they are collected. ��exc_info�formatted_tbc C s || _ d | _d S �Nr ��selfr r r r �__init__t � z_TracebackLogger.__init__c C s( | j }|d urd | _ tj|� | _d S d S r )r � traceback�format_exceptionr r r r r �activatex s �z_TracebackLogger.activatec C s d | _ d | _d S r r �r r r r �clear~ r z_TracebackLogger.clearc C s0 |� s| j rt�dd�| j ��� � d S d S d S )Nz(Future exception was never retrieved: %s� )r r �error�join�rstrip)r r r r r �__del__� s ��z_TracebackLogger.__del__N) r r r �__doc__� __slots__r r r"