doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
set_name(value) Set the name of the Task. The value argument can be any object, which is then converted to a string. In the default Task implementation, the name will be visible in the repr() output of a task object. New in version 3.8.
python.library.asyncio-task#asyncio.Task.set_name
class asyncio.ThreadedChildWatcher This implementation starts a new waiting thread for every subprocess spawn. It works reliably even when the asyncio event loop is run in a non-main OS thread. There is no noticeable overhead when handling a big number of children (O(1) each time a child terminates), but starting a t...
python.library.asyncio-policy#asyncio.ThreadedChildWatcher
exception asyncio.TimeoutError The operation has exceeded the given deadline. Important This exception is different from the builtin TimeoutError exception.
python.library.asyncio-exceptions#asyncio.TimeoutError
class asyncio.TimerHandle A callback wrapper object returned by loop.call_later(), and loop.call_at(). This class is a subclass of Handle. when() Return a scheduled callback time as float seconds. The time is an absolute timestamp, using the same time reference as loop.time(). New in version 3.7.
python.library.asyncio-eventloop#asyncio.TimerHandle
when() Return a scheduled callback time as float seconds. The time is an absolute timestamp, using the same time reference as loop.time(). New in version 3.7.
python.library.asyncio-eventloop#asyncio.TimerHandle.when
coroutine asyncio.to_thread(func, /, *args, **kwargs) Asynchronously run function func in a separate thread. Any *args and **kwargs supplied for this function are directly passed to func. Also, the current contextvars.Context is propagated, allowing context variables from the event loop thread to be accessed in the s...
python.library.asyncio-task#asyncio.to_thread
class asyncio.Transport(WriteTransport, ReadTransport) Interface representing a bidirectional transport, such as a TCP connection. The user does not instantiate a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. Insta...
python.library.asyncio-protocol#asyncio.Transport
coroutine asyncio.wait(aws, *, loop=None, timeout=None, return_when=ALL_COMPLETED) Run awaitable objects in the aws iterable concurrently and block until the condition specified by return_when. The aws iterable must not be empty. Returns two sets of Tasks/Futures: (done, pending). Usage: done, pending = await asyncio...
python.library.asyncio-task#asyncio.wait
coroutine asyncio.wait_for(aw, timeout, *, loop=None) Wait for the aw awaitable to complete with a timeout. If aw is a coroutine it is automatically scheduled as a Task. timeout can either be None or a float or int number of seconds to wait for. If timeout is None, block until the future completes. If a timeout occur...
python.library.asyncio-task#asyncio.wait_for
class asyncio.WindowsProactorEventLoopPolicy An alternative event loop policy that uses the ProactorEventLoop event loop implementation. Availability: Windows.
python.library.asyncio-policy#asyncio.WindowsProactorEventLoopPolicy
class asyncio.WindowsSelectorEventLoopPolicy An alternative event loop policy that uses the SelectorEventLoop event loop implementation. Availability: Windows.
python.library.asyncio-policy#asyncio.WindowsSelectorEventLoopPolicy
asyncio.wrap_future(future, *, loop=None) Wrap a concurrent.futures.Future object in a asyncio.Future object.
python.library.asyncio-future#asyncio.wrap_future
class asyncio.WriteTransport(BaseTransport) A base transport for write-only connections. Instances of the WriteTransport class are returned from the loop.connect_write_pipe() event loop method and are also used by subprocess-related methods like loop.subprocess_exec().
python.library.asyncio-protocol#asyncio.WriteTransport
WriteTransport.abort() Close the transport immediately, without waiting for pending operations to complete. Buffered data will be lost. No more data will be received. The protocol’s protocol.connection_lost() method will eventually be called with None as its argument.
python.library.asyncio-protocol#asyncio.WriteTransport.abort
WriteTransport.can_write_eof() Return True if the transport supports write_eof(), False if not.
python.library.asyncio-protocol#asyncio.WriteTransport.can_write_eof
WriteTransport.get_write_buffer_limits() Get the high and low watermarks for write flow control. Return a tuple (low, high) where low and high are positive number of bytes. Use set_write_buffer_limits() to set the limits. New in version 3.4.2.
python.library.asyncio-protocol#asyncio.WriteTransport.get_write_buffer_limits
WriteTransport.get_write_buffer_size() Return the current size of the output buffer used by the transport.
python.library.asyncio-protocol#asyncio.WriteTransport.get_write_buffer_size
WriteTransport.set_write_buffer_limits(high=None, low=None) Set the high and low watermarks for write flow control. These two values (measured in number of bytes) control when the protocol’s protocol.pause_writing() and protocol.resume_writing() methods are called. If specified, the low watermark must be less than or...
python.library.asyncio-protocol#asyncio.WriteTransport.set_write_buffer_limits
WriteTransport.write(data) Write some data bytes to the transport. This method does not block; it buffers the data and arranges for it to be sent out asynchronously.
python.library.asyncio-protocol#asyncio.WriteTransport.write
WriteTransport.writelines(list_of_data) Write a list (or any iterable) of data bytes to the transport. This is functionally equivalent to calling write() on each element yielded by the iterable, but may be implemented more efficiently.
python.library.asyncio-protocol#asyncio.WriteTransport.writelines
WriteTransport.write_eof() Close the write end of the transport after flushing all buffered data. Data may still be received. This method can raise NotImplementedError if the transport (e.g. SSL) doesn’t support half-closed connections.
python.library.asyncio-protocol#asyncio.WriteTransport.write_eof
asyncore — Asynchronous socket handler Source code: Lib/asyncore.py Deprecated since version 3.6: Please use asyncio instead. Note This module exists for backwards compatibility only. For new code we recommend using asyncio. This module provides the basic infrastructure for writing asynchronous socket service clien...
python.library.asyncore
class asyncore.dispatcher The dispatcher class is a thin wrapper around a low-level socket object. To make it more useful, it has a few methods for event-handling which are called from the asynchronous loop. Otherwise, it can be treated as a normal non-blocking socket object. The firing of low-level events at certain...
python.library.asyncore#asyncore.dispatcher
accept() Accept a connection. The socket must be bound to an address and listening for connections. The return value can be either None or a pair (conn, address) where conn is a new socket object usable to send and receive data on the connection, and address is the address bound to the socket on the other end of the ...
python.library.asyncore#asyncore.dispatcher.accept
bind(address) Bind the socket to address. The socket must not already be bound. (The format of address depends on the address family — refer to the socket documentation for more information.) To mark the socket as re-usable (setting the SO_REUSEADDR option), call the dispatcher object’s set_reuse_addr() method.
python.library.asyncore#asyncore.dispatcher.bind
close() Close the socket. All future operations on the socket object will fail. The remote end-point will receive no more data (after queued data is flushed). Sockets are automatically closed when they are garbage-collected.
python.library.asyncore#asyncore.dispatcher.close
connect(address) As with the normal socket object, address is a tuple with the first element the host to connect to, and the second the port number.
python.library.asyncore#asyncore.dispatcher.connect
create_socket(family=socket.AF_INET, type=socket.SOCK_STREAM) This is identical to the creation of a normal socket, and will use the same options for creation. Refer to the socket documentation for information on creating sockets. Changed in version 3.3: family and type arguments can be omitted.
python.library.asyncore#asyncore.dispatcher.create_socket
handle_accept() Called on listening channels (passive openers) when a connection can be established with a new remote endpoint that has issued a connect() call for the local endpoint. Deprecated in version 3.2; use handle_accepted() instead. Deprecated since version 3.2.
python.library.asyncore#asyncore.dispatcher.handle_accept
handle_accepted(sock, addr) Called on listening channels (passive openers) when a connection has been established with a new remote endpoint that has issued a connect() call for the local endpoint. sock is a new socket object usable to send and receive data on the connection, and addr is the address bound to the sock...
python.library.asyncore#asyncore.dispatcher.handle_accepted
handle_close() Called when the socket is closed.
python.library.asyncore#asyncore.dispatcher.handle_close
handle_connect() Called when the active opener’s socket actually makes a connection. Might send a “welcome” banner, or initiate a protocol negotiation with the remote endpoint, for example.
python.library.asyncore#asyncore.dispatcher.handle_connect
handle_error() Called when an exception is raised and not otherwise handled. The default version prints a condensed traceback.
python.library.asyncore#asyncore.dispatcher.handle_error
handle_expt() Called when there is out of band (OOB) data for a socket connection. This will almost never happen, as OOB is tenuously supported and rarely used.
python.library.asyncore#asyncore.dispatcher.handle_expt
handle_read() Called when the asynchronous loop detects that a read() call on the channel’s socket will succeed.
python.library.asyncore#asyncore.dispatcher.handle_read
handle_write() Called when the asynchronous loop detects that a writable socket can be written. Often this method will implement the necessary buffering for performance. For example: def handle_write(self): sent = self.send(self.buffer) self.buffer = self.buffer[sent:]
python.library.asyncore#asyncore.dispatcher.handle_write
listen(backlog) Listen for connections made to the socket. The backlog argument specifies the maximum number of queued connections and should be at least 1; the maximum value is system-dependent (usually 5).
python.library.asyncore#asyncore.dispatcher.listen
readable() Called each time around the asynchronous loop to determine whether a channel’s socket should be added to the list on which read events can occur. The default method simply returns True, indicating that by default, all channels will be interested in read events.
python.library.asyncore#asyncore.dispatcher.readable
recv(buffer_size) Read at most buffer_size bytes from the socket’s remote end-point. An empty bytes object implies that the channel has been closed from the other end. Note that recv() may raise BlockingIOError , even though select.select() or select.poll() has reported the socket ready for reading.
python.library.asyncore#asyncore.dispatcher.recv
send(data) Send data to the remote end-point of the socket.
python.library.asyncore#asyncore.dispatcher.send
writable() Called each time around the asynchronous loop to determine whether a channel’s socket should be added to the list on which write events can occur. The default method simply returns True, indicating that by default, all channels will be interested in write events.
python.library.asyncore#asyncore.dispatcher.writable
class asyncore.dispatcher_with_send A dispatcher subclass which adds simple buffered output capability, useful for simple clients. For more sophisticated usage use asynchat.async_chat.
python.library.asyncore#asyncore.dispatcher_with_send
class asyncore.file_dispatcher A file_dispatcher takes a file descriptor or file object along with an optional map argument and wraps it for use with the poll() or loop() functions. If provided a file object or anything with a fileno() method, that method will be called and passed to the file_wrapper constructor. Ava...
python.library.asyncore#asyncore.file_dispatcher
class asyncore.file_wrapper A file_wrapper takes an integer file descriptor and calls os.dup() to duplicate the handle so that the original handle may be closed independently of the file_wrapper. This class implements sufficient methods to emulate a socket for use by the file_dispatcher class. Availability: Unix.
python.library.asyncore#asyncore.file_wrapper
asyncore.loop([timeout[, use_poll[, map[, count]]]]) Enter a polling loop that terminates after count passes or all open channels have been closed. All arguments are optional. The count parameter defaults to None, resulting in the loop terminating only when all channels have been closed. The timeout argument sets the...
python.library.asyncore#asyncore.loop
atexit — Exit handlers The atexit module defines functions to register and unregister cleanup functions. Functions thus registered are automatically executed upon normal interpreter termination. atexit runs these functions in the reverse order in which they were registered; if you register A, B, and C, at interpreter t...
python.library.atexit
atexit.register(func, *args, **kwargs) Register func as a function to be executed at termination. Any optional arguments that are to be passed to func must be passed as arguments to register(). It is possible to register the same function and arguments more than once. At normal program termination (for instance, if s...
python.library.atexit#atexit.register
atexit.unregister(func) Remove func from the list of functions to be run at interpreter shutdown. After calling unregister(), func is guaranteed not to be called when the interpreter shuts down, even if it was registered more than once. unregister() silently does nothing if func was not previously registered.
python.library.atexit#atexit.unregister
exception AttributeError Raised when an attribute reference (see Attribute references) or assignment fails. (When an object does not support attribute references or attribute assignments at all, TypeError is raised.)
python.library.exceptions#AttributeError
audioop — Manipulate raw audio data The audioop module contains some useful operations on sound fragments. It operates on sound fragments consisting of signed integer samples 8, 16, 24 or 32 bits wide, stored in bytes-like objects. All scalar items are integers, unless specified otherwise. Changed in version 3.4: Supp...
python.library.audioop
audioop.add(fragment1, fragment2, width) Return a fragment which is the addition of the two samples passed as parameters. width is the sample width in bytes, either 1, 2, 3 or 4. Both fragments should have the same length. Samples are truncated in case of overflow.
python.library.audioop#audioop.add
audioop.adpcm2lin(adpcmfragment, width, state) Decode an Intel/DVI ADPCM coded fragment to a linear fragment. See the description of lin2adpcm() for details on ADPCM coding. Return a tuple (sample, newstate) where the sample has the width specified in width.
python.library.audioop#audioop.adpcm2lin
audioop.alaw2lin(fragment, width) Convert sound fragments in a-LAW encoding to linearly encoded sound fragments. a-LAW encoding always uses 8 bits samples, so width refers only to the sample width of the output fragment here.
python.library.audioop#audioop.alaw2lin
audioop.avg(fragment, width) Return the average over all samples in the fragment.
python.library.audioop#audioop.avg
audioop.avgpp(fragment, width) Return the average peak-peak value over all samples in the fragment. No filtering is done, so the usefulness of this routine is questionable.
python.library.audioop#audioop.avgpp
audioop.bias(fragment, width, bias) Return a fragment that is the original fragment with a bias added to each sample. Samples wrap around in case of overflow.
python.library.audioop#audioop.bias
audioop.byteswap(fragment, width) “Byteswap” all samples in a fragment and returns the modified fragment. Converts big-endian samples to little-endian and vice versa. New in version 3.4.
python.library.audioop#audioop.byteswap
audioop.cross(fragment, width) Return the number of zero crossings in the fragment passed as an argument.
python.library.audioop#audioop.cross
exception audioop.error This exception is raised on all errors, such as unknown number of bytes per sample, etc.
python.library.audioop#audioop.error
audioop.findfactor(fragment, reference) Return a factor F such that rms(add(fragment, mul(reference, -F))) is minimal, i.e., return the factor with which you should multiply reference to make it match as well as possible to fragment. The fragments should both contain 2-byte samples. The time taken by this routine is ...
python.library.audioop#audioop.findfactor
audioop.findfit(fragment, reference) Try to match reference as well as possible to a portion of fragment (which should be the longer fragment). This is (conceptually) done by taking slices out of fragment, using findfactor() to compute the best match, and minimizing the result. The fragments should both contain 2-byt...
python.library.audioop#audioop.findfit
audioop.findmax(fragment, length) Search fragment for a slice of length length samples (not bytes!) with maximum energy, i.e., return i for which rms(fragment[i*2:(i+length)*2]) is maximal. The fragments should both contain 2-byte samples. The routine takes time proportional to len(fragment).
python.library.audioop#audioop.findmax
audioop.getsample(fragment, width, index) Return the value of sample index from the fragment.
python.library.audioop#audioop.getsample
audioop.lin2adpcm(fragment, width, state) Convert samples to 4 bit Intel/DVI ADPCM encoding. ADPCM coding is an adaptive coding scheme, whereby each 4 bit number is the difference between one sample and the next, divided by a (varying) step. The Intel/DVI ADPCM algorithm has been selected for use by the IMA, so it ma...
python.library.audioop#audioop.lin2adpcm
audioop.lin2alaw(fragment, width) Convert samples in the audio fragment to a-LAW encoding and return this as a bytes object. a-LAW is an audio encoding format whereby you get a dynamic range of about 13 bits using only 8 bit samples. It is used by the Sun audio hardware, among others.
python.library.audioop#audioop.lin2alaw
audioop.lin2lin(fragment, width, newwidth) Convert samples between 1-, 2-, 3- and 4-byte formats. Note In some audio formats, such as .WAV files, 16, 24 and 32 bit samples are signed, but 8 bit samples are unsigned. So when converting to 8 bit wide samples for these formats, you need to also add 128 to the result: n...
python.library.audioop#audioop.lin2lin
audioop.lin2ulaw(fragment, width) Convert samples in the audio fragment to u-LAW encoding and return this as a bytes object. u-LAW is an audio encoding format whereby you get a dynamic range of about 14 bits using only 8 bit samples. It is used by the Sun audio hardware, among others.
python.library.audioop#audioop.lin2ulaw
audioop.max(fragment, width) Return the maximum of the absolute value of all samples in a fragment.
python.library.audioop#audioop.max
audioop.maxpp(fragment, width) Return the maximum peak-peak value in the sound fragment.
python.library.audioop#audioop.maxpp
audioop.minmax(fragment, width) Return a tuple consisting of the minimum and maximum values of all samples in the sound fragment.
python.library.audioop#audioop.minmax
audioop.mul(fragment, width, factor) Return a fragment that has all samples in the original fragment multiplied by the floating-point value factor. Samples are truncated in case of overflow.
python.library.audioop#audioop.mul
audioop.ratecv(fragment, width, nchannels, inrate, outrate, state[, weightA[, weightB]]) Convert the frame rate of the input fragment. state is a tuple containing the state of the converter. The converter returns a tuple (newfragment, newstate), and newstate should be passed to the next call of ratecv(). The initial ...
python.library.audioop#audioop.ratecv
audioop.reverse(fragment, width) Reverse the samples in a fragment and returns the modified fragment.
python.library.audioop#audioop.reverse
audioop.rms(fragment, width) Return the root-mean-square of the fragment, i.e. sqrt(sum(S_i^2)/n). This is a measure of the power in an audio signal.
python.library.audioop#audioop.rms
audioop.tomono(fragment, width, lfactor, rfactor) Convert a stereo fragment to a mono fragment. The left channel is multiplied by lfactor and the right channel by rfactor before adding the two channels to give a mono signal.
python.library.audioop#audioop.tomono
audioop.tostereo(fragment, width, lfactor, rfactor) Generate a stereo fragment from a mono fragment. Each pair of samples in the stereo fragment are computed from the mono sample, whereby left channel samples are multiplied by lfactor and right channel samples by rfactor.
python.library.audioop#audioop.tostereo
audioop.ulaw2lin(fragment, width) Convert sound fragments in u-LAW encoding to linearly encoded sound fragments. u-LAW encoding always uses 8 bits samples, so width refers only to the sample width of the output fragment here.
python.library.audioop#audioop.ulaw2lin
base64 — Base16, Base32, Base64, Base85 Data Encodings Source code: Lib/base64.py This module provides functions for encoding binary data to printable ASCII characters and decoding such encodings back to binary data. It provides encoding and decoding functions for the encodings specified in RFC 3548, which defines the ...
python.library.base64
base64.a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \t\n\r\v') Decode the Ascii85 encoded bytes-like object or ASCII string b and return the decoded bytes. foldspaces is a flag that specifies whether the ‘y’ short sequence should be accepted as shorthand for 4 consecutive spaces (ASCII 0x20). This fe...
python.library.base64#base64.a85decode
base64.a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False) Encode the bytes-like object b using Ascii85 and return the encoded bytes. foldspaces is an optional flag that uses the special short sequence ‘y’ instead of 4 consecutive spaces (ASCII 0x20) as supported by ‘btoa’. This feature is not suppor...
python.library.base64#base64.a85encode
base64.b16decode(s, casefold=False) Decode the Base16 encoded bytes-like object or ASCII string s and return the decoded bytes. Optional casefold is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is False. A binascii.Error is raised if s is incorrectly padded...
python.library.base64#base64.b16decode
base64.b16encode(s) Encode the bytes-like object s using Base16 and return the encoded bytes.
python.library.base64#base64.b16encode
base64.b32decode(s, casefold=False, map01=None) Decode the Base32 encoded bytes-like object or ASCII string s and return the decoded bytes. Optional casefold is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is False. RFC 3548 allows for optional mapping of t...
python.library.base64#base64.b32decode
base64.b32encode(s) Encode the bytes-like object s using Base32 and return the encoded bytes.
python.library.base64#base64.b32encode
base64.b64decode(s, altchars=None, validate=False) Decode the Base64 encoded bytes-like object or ASCII string s and return the decoded bytes. Optional altchars must be a bytes-like object or ASCII string of at least length 2 (additional characters are ignored) which specifies the alternative alphabet used instead of...
python.library.base64#base64.b64decode
base64.b64encode(s, altchars=None) Encode the bytes-like object s using Base64 and return the encoded bytes. Optional altchars must be a bytes-like object of at least length 2 (additional characters are ignored) which specifies an alternative alphabet for the + and / characters. This allows an application to e.g. gen...
python.library.base64#base64.b64encode
base64.b85decode(b) Decode the base85-encoded bytes-like object or ASCII string b and return the decoded bytes. Padding is implicitly removed, if necessary. New in version 3.4.
python.library.base64#base64.b85decode
base64.b85encode(b, pad=False) Encode the bytes-like object b using base85 (as used in e.g. git-style binary diffs) and return the encoded bytes. If pad is true, the input is padded with b'\0' so its length is a multiple of 4 bytes before encoding. New in version 3.4.
python.library.base64#base64.b85encode
base64.decode(input, output) Decode the contents of the binary input file and write the resulting binary data to the output file. input and output must be file objects. input will be read until input.readline() returns an empty bytes object.
python.library.base64#base64.decode
base64.decodebytes(s) Decode the bytes-like object s, which must contain one or more lines of base64 encoded data, and return the decoded bytes. New in version 3.1.
python.library.base64#base64.decodebytes
base64.encode(input, output) Encode the contents of the binary input file and write the resulting base64 encoded data to the output file. input and output must be file objects. input will be read until input.read() returns an empty bytes object. encode() inserts a newline character (b'\n') after every 76 bytes of the...
python.library.base64#base64.encode
base64.encodebytes(s) Encode the bytes-like object s, which can contain arbitrary binary data, and return bytes containing the base64-encoded data, with newlines (b'\n') inserted after every 76 bytes of output, and ensuring that there is a trailing newline, as per RFC 2045 (MIME). New in version 3.1.
python.library.base64#base64.encodebytes
base64.standard_b64decode(s) Decode bytes-like object or ASCII string s using the standard Base64 alphabet and return the decoded bytes.
python.library.base64#base64.standard_b64decode
base64.standard_b64encode(s) Encode bytes-like object s using the standard Base64 alphabet and return the encoded bytes.
python.library.base64#base64.standard_b64encode
base64.urlsafe_b64decode(s) Decode bytes-like object or ASCII string s using the URL- and filesystem-safe alphabet, which substitutes - instead of + and _ instead of / in the standard Base64 alphabet, and return the decoded bytes.
python.library.base64#base64.urlsafe_b64decode
base64.urlsafe_b64encode(s) Encode bytes-like object s using the URL- and filesystem-safe alphabet, which substitutes - instead of + and _ instead of / in the standard Base64 alphabet, and return the encoded bytes. The result can still contain =.
python.library.base64#base64.urlsafe_b64encode
exception BaseException The base class for all built-in exceptions. It is not meant to be directly inherited by user-defined classes (for that, use Exception). If str() is called on an instance of this class, the representation of the argument(s) to the instance are returned, or the empty string when there were no ar...
python.library.exceptions#BaseException
args The tuple of arguments given to the exception constructor. Some built-in exceptions (like OSError) expect a certain number of arguments and assign a special meaning to the elements of this tuple, while others are usually called only with a single string giving an error message.
python.library.exceptions#BaseException.args
with_traceback(tb) This method sets tb as the new traceback for the exception and returns the exception object. It is usually used in exception handling code like this: try: ... except SomeException: tb = sys.exc_info()[2] raise OtherException(...).with_traceback(tb)
python.library.exceptions#BaseException.with_traceback
bdb — Debugger framework Source code: Lib/bdb.py The bdb module handles basic debugger functions, like setting breakpoints or managing execution via the debugger. The following exception is defined: exception bdb.BdbQuit Exception raised by the Bdb class for quitting the debugger. The bdb module also defines two ...
python.library.bdb