neulab/docprompting-conala huggingface dataset:
coroutine loop.sendfile(transport, file, offset=0, count=None, *, fallback=True)  
Send a file over a transport. Return the total number of bytes sent. The method uses high-performance os.sendfile() if available. file must be a regular file object opened in binary mode. offset tells from where to start reading the file. If specified, count is the total number of bytes to transmit as opposed to sending the file until EOF is reached. File position is always updated, even when this method raises an error, and file.tell() can be used to obtain the actual number of bytes sent. fallback set to True makes asyncio to manually read and send the file when the platform does not support the sendfile system call (e.g. Windows or SSL socket on Unix). Raise SendfileNotAvailableError if the system does not support the sendfile syscall and fallback is False.  New in version 3.7.
loop.set_debug(enabled: bool)  
Set the debug mode of the event loop.  Changed in version 3.7: The new Python Development Mode can now also be used to enable the debug mode.
loop.set_default_executor(executor)  
Set executor as the default executor used by run_in_executor(). executor should be an instance of ThreadPoolExecutor.  Deprecated since version 3.8: Using an executor that is not an instance of ThreadPoolExecutor is deprecated and will trigger an error in Python 3.9.  executor must be an instance of concurrent.futures.ThreadPoolExecutor.
loop.set_exception_handler(handler)  
Set handler as the new event loop exception handler. If handler is None, the default exception handler will be set. Otherwise, handler must be a callable with the signature matching (loop, context), where loop is a reference to the active event loop, and context is a dict object containing the details of the exception (see call_exception_handler() documentation for details about context).
loop.set_task_factory(factory)  
Set a task factory that will be used by loop.create_task(). If factory is None the default task factory will be set. Otherwise, factory must be a callable with the signature matching (loop, coro), where loop is a reference to the active event loop, and coro is a coroutine object. The callable must return a asyncio.Future-compatible object.
coroutine loop.shutdown_asyncgens()  
Schedule all currently open asynchronous generator objects to close with an aclose() call. After calling this method, the event loop will issue a warning if a new asynchronous generator is iterated. This should be used to reliably finalize all scheduled asynchronous generators. Note that there is no need to call this function when asyncio.run() is used. Example: try:
    loop.run_forever()
finally:
    loop.run_until_complete(loop.shutdown_asyncgens())
    loop.close()
  New in version 3.6.
coroutine loop.shutdown_default_executor()  
Schedule the closure of the default executor and wait for it to join all of the threads in the ThreadPoolExecutor. After calling this method, a RuntimeError will be raised if loop.run_in_executor() is called while using the default executor. Note that there is no need to call this function when asyncio.run() is used.  New in version 3.9.
coroutine loop.sock_accept(sock)  
Accept a connection. Modeled after the blocking socket.accept() method. The socket must be bound to an address and listening for connections. The return value is 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 connection. sock must be a non-blocking socket.  Changed in version 3.7: Even though the method was always documented as a coroutine method, before Python 3.7 it returned a Future. Since Python 3.7, this is an async def method.   See also loop.create_server() and start_server().
coroutine loop.sock_connect(sock, address)  
Connect sock to a remote socket at address. Asynchronous version of socket.connect(). sock must be a non-blocking socket.  Changed in version 3.5.2: address no longer needs to be resolved. sock_connect will try to check if the address is already resolved by calling socket.inet_pton(). If not, loop.getaddrinfo() will be used to resolve the address.   See also loop.create_connection() and asyncio.open_connection().
coroutine loop.sock_recv(sock, nbytes)  
Receive up to nbytes from sock. Asynchronous version of socket.recv(). Return the received data as a bytes object. sock must be a non-blocking socket.  Changed in version 3.7: Even though this method was always documented as a coroutine method, releases before Python 3.7 returned a Future. Since Python 3.7 this is an async def method.
coroutine loop.sock_recv_into(sock, buf)  
Receive data from sock into the buf buffer. Modeled after the blocking socket.recv_into() method. Return the number of bytes written to the buffer. sock must be a non-blocking socket.  New in version 3.7.
coroutine loop.sock_sendall(sock, data)  
Send data to the sock socket. Asynchronous version of socket.sendall(). This method continues to send to the socket until either all data in data has been sent or an error occurs. None is returned on success. On error, an exception is raised. Additionally, there is no way to determine how much data, if any, was successfully processed by the receiving end of the connection. sock must be a non-blocking socket.  Changed in version 3.7: Even though the method was always documented as a coroutine method, before Python 3.7 it returned an Future. Since Python 3.7, this is an async def method.
coroutine loop.sock_sendfile(sock, file, offset=0, count=None, *, fallback=True)  
Send a file using high-performance os.sendfile if possible. Return the total number of bytes sent. Asynchronous version of socket.sendfile(). sock must be a non-blocking socket.SOCK_STREAM socket. file must be a regular file object open in binary mode. offset tells from where to start reading the file. If specified, count is the total number of bytes to transmit as opposed to sending the file until EOF is reached. File position is always updated, even when this method raises an error, and file.tell() can be used to obtain the actual number of bytes sent. fallback, when set to True, makes asyncio manually read and send the file when the platform does not support the sendfile syscall (e.g. Windows or SSL socket on Unix). Raise SendfileNotAvailableError if the system does not support sendfile syscall and fallback is False. sock must be a non-blocking socket.  New in version 3.7.
coroutine loop.start_tls(transport, protocol, sslcontext, *, server_side=False, server_hostname=None, ssl_handshake_timeout=None)  
Upgrade an existing transport-based connection to TLS. Return a new transport instance, that the protocol must start using immediately after the await. The transport instance passed to the start_tls method should never be used again. Parameters:  
transport and protocol instances that methods like create_server() and create_connection() return. 
sslcontext: a configured instance of SSLContext. 
server_side pass True when a server-side connection is being upgraded (like the one created by create_server()). 
server_hostname: sets or overrides the host name that the target server’s certificate will be matched against. 
ssl_handshake_timeout is (for a TLS connection) the time in seconds to wait for the TLS handshake to complete before aborting the connection. 60.0 seconds if None (default).   New in version 3.7.
coroutine loop.subprocess_exec(protocol_factory, *args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)  
Create a subprocess from one or more string arguments specified by args. args must be a list of strings represented by:  
str; or bytes, encoded to the filesystem encoding.  The first string specifies the program executable, and the remaining strings specify the arguments. Together, string arguments form the argv of the program. This is similar to the standard library subprocess.Popen class called with shell=False and the list of strings passed as the first argument; however, where Popen takes a single argument which is list of strings, subprocess_exec takes multiple string arguments. The protocol_factory must be a callable returning a subclass of the asyncio.SubprocessProtocol class. Other parameters:  
stdin can be any of these:  a file-like object representing a pipe to be connected to the subprocess’s standard input stream using connect_write_pipe()
 the subprocess.PIPE constant (default) which will create a new pipe and connect it, the value None which will make the subprocess inherit the file descriptor from this process the subprocess.DEVNULL constant which indicates that the special os.devnull file will be used   
stdout can be any of these:  a file-like object representing a pipe to be connected to the subprocess’s standard output stream using connect_write_pipe()
 the subprocess.PIPE constant (default) which will create a new pipe and connect it, the value None which will make the subprocess inherit the file descriptor from this process the subprocess.DEVNULL constant which indicates that the special os.devnull file will be used   
stderr can be any of these:  a file-like object representing a pipe to be connected to the subprocess’s standard error stream using connect_write_pipe()
 the subprocess.PIPE constant (default) which will create a new pipe and connect it, the value None which will make the subprocess inherit the file descriptor from this process the subprocess.DEVNULL constant which indicates that the special os.devnull file will be used the subprocess.STDOUT constant which will connect the standard error stream to the process’ standard output stream   
All other keyword arguments are passed to subprocess.Popen without interpretation, except for bufsize, universal_newlines, shell, text, encoding and errors, which should not be specified at all. The asyncio subprocess API does not support decoding the streams as text. bytes.decode() can be used to convert the bytes returned from the stream to text.   See the constructor of the subprocess.Popen class for documentation on other arguments. Returns a pair of (transport, protocol), where transport conforms to the asyncio.SubprocessTransport base class and protocol is an object instantiated by the protocol_factory.
coroutine loop.subprocess_shell(protocol_factory, cmd, *, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)  
Create a subprocess from cmd, which can be a str or a bytes string encoded to the filesystem encoding, using the platform’s “shell” syntax. This is similar to the standard library subprocess.Popen class called with shell=True. The protocol_factory must be a callable returning a subclass of the SubprocessProtocol class. See subprocess_exec() for more details about the remaining arguments. Returns a pair of (transport, protocol), where transport conforms to the SubprocessTransport base class and protocol is an object instantiated by the protocol_factory.
loop.time()  
Return the current time, as a float value, according to the event loop’s internal monotonic clock.
class asyncio.MultiLoopChildWatcher  
This implementation registers a SIGCHLD signal handler on instantiation. That can break third-party code that installs a custom handler for SIGCHLD signal. The watcher avoids disrupting other code spawning processes by polling every process explicitly on a SIGCHLD signal. There is no limitation for running subprocesses from different threads once the watcher is installed. The solution is safe but it has a significant overhead when handling a big number of processes (O(n) each time a SIGCHLD is received).  New in version 3.8.
coroutine asyncio.open_connection(host=None, port=None, *, loop=None, limit=None, ssl=None, family=0, proto=0, flags=0, sock=None, local_addr=None, server_hostname=None, ssl_handshake_timeout=None)  
Establish a network connection and return a pair of (reader, writer) objects. The returned reader and writer objects are instances of StreamReader and StreamWriter classes. The loop argument is optional and can always be determined automatically when this function is awaited from a coroutine. limit determines the buffer size limit used by the returned StreamReader instance. By default the limit is set to 64 KiB. The rest of the arguments are passed directly to loop.create_connection().  New in version 3.7: The ssl_handshake_timeout parameter.
coroutine asyncio.open_unix_connection(path=None, *, loop=None, limit=None, ssl=None, sock=None, server_hostname=None, ssl_handshake_timeout=None)  
Establish a Unix socket connection and return a pair of (reader, writer). Similar to open_connection() but operates on Unix sockets. See also the documentation of loop.create_unix_connection(). Availability: Unix.  New in version 3.7: The ssl_handshake_timeout parameter.   Changed in version 3.7: The path parameter can now be a path-like object
class asyncio.PidfdChildWatcher  
This implementation polls process file descriptors (pidfds) to await child process termination. In some respects, PidfdChildWatcher is a “Goldilocks” child watcher implementation. It doesn’t require signals or threads, doesn’t interfere with any processes launched outside the event loop, and scales linearly with the number of subprocesses launched by the event loop. The main disadvantage is that pidfds are specific to Linux, and only work on recent (5.3+) kernels.  New in version 3.9.
class asyncio.PriorityQueue  
A variant of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form (priority_number, data).
class asyncio.ProactorEventLoop  
An event loop for Windows that uses “I/O Completion Ports” (IOCP). Availability: Windows.  See also MSDN documentation on I/O Completion Ports.
class asyncio.Protocol(BaseProtocol)  
The base class for implementing streaming protocols (TCP, Unix sockets, etc).
Protocol.data_received(data)  
Called when some data is received. data is a non-empty bytes object containing the incoming data. Whether the data is buffered, chunked or reassembled depends on the transport. In general, you shouldn’t rely on specific semantics and instead make your parsing generic and flexible. However, data is always received in the correct order. The method can be called an arbitrary number of times while a connection is open. However, protocol.eof_received() is called at most once. Once eof_received() is called, data_received() is not called anymore.
Protocol.eof_received()  
Called when the other end signals it won’t send any more data (for example by calling transport.write_eof(), if the other end also uses asyncio). This method may return a false value (including None), in which case the transport will close itself. Conversely, if this method returns a true value, the protocol used determines whether to close the transport. Since the default implementation returns None, it implicitly closes the connection. Some transports, including SSL, don’t support half-closed connections, in which case returning true from this method will result in the connection being closed.
class asyncio.Queue(maxsize=0, *, loop=None)  
A first in, first out (FIFO) queue. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then await put() blocks when the queue reaches maxsize until an item is removed by get(). Unlike the standard library threading queue, the size of the queue is always known and can be returned by calling the qsize() method.  Deprecated since version 3.8, will be removed in version 3.10: The loop parameter.  This class is not thread safe.  
maxsize  
Number of items allowed in the queue. 
  
empty()  
Return True if the queue is empty, False otherwise. 
  
full()  
Return True if there are maxsize items in the queue. If the queue was initialized with maxsize=0 (the default), then full() never returns True. 
  
coroutine get()  
Remove and return an item from the queue. If queue is empty, wait until an item is available. 
  
get_nowait()  
Return an item if one is immediately available, else raise QueueEmpty. 
  
coroutine join()  
Block until all items in the queue have been received and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer coroutine calls task_done() to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks. 
  
coroutine put(item)  
Put an item into the queue. If the queue is full, wait until a free slot is available before adding the item. 
  
put_nowait(item)  
Put an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. 
  
qsize()  
Return the number of items in the queue. 
  
task_done()  
Indicate that a formerly enqueued task is complete. Used by queue consumers. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue). Raises ValueError if called more times than there were items placed in the queue.
full()  
Return True if there are maxsize items in the queue. If the queue was initialized with maxsize=0 (the default), then full() never returns True.
coroutine get()  
Remove and return an item from the queue. If queue is empty, wait until an item is available.
get_nowait()  
Return an item if one is immediately available, else raise QueueEmpty.
coroutine join()  
Block until all items in the queue have been received and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer coroutine calls task_done() to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks.
coroutine put(item)  
Put an item into the queue. If the queue is full, wait until a free slot is available before adding the item.
put_nowait(item)  
Put an item into the queue without blocking. If no free slot is immediately available, raise QueueFull.
task_done()  
Indicate that a formerly enqueued task is complete. Used by queue consumers. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue). Raises ValueError if called more times than there were items placed in the queue.
exception asyncio.QueueEmpty  
This exception is raised when the get_nowait() method is called on an empty queue.
exception asyncio.QueueFull  
Exception raised when the put_nowait() method is called on a queue that has reached its maxsize.
class asyncio.ReadTransport(BaseTransport)  
A base transport for read-only connections. Instances of the ReadTransport class are returned from the loop.connect_read_pipe() event loop method and are also used by subprocess-related methods like loop.subprocess_exec().
ReadTransport.is_reading()  
Return True if the transport is receiving new data.  New in version 3.7.
ReadTransport.pause_reading()  
Pause the receiving end of the transport. No data will be passed to the protocol’s protocol.data_received() method until resume_reading() is called.  Changed in version 3.7: The method is idempotent, i.e. it can be called when the transport is already paused or closed.
ReadTransport.resume_reading()  
Resume the receiving end. The protocol’s protocol.data_received() method will be called once again if some data is available for reading.  Changed in version 3.7: The method is idempotent, i.e. it can be called when the transport is already reading.
asyncio.run(coro, *, debug=False)  
Execute the coroutine coro and return the result. This function runs the passed coroutine, taking care of managing the asyncio event loop, finalizing asynchronous generators, and closing the threadpool. This function cannot be called when another asyncio event loop is running in the same thread. If debug is True, the event loop will be run in debug mode. This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once. Example: async def main():
    await asyncio.sleep(1)
    print('hello')

asyncio.run(main())
  New in version 3.7.   Changed in version 3.9: Updated to use loop.shutdown_default_executor().   Note The source code for asyncio.run() can be found in Lib/asyncio/runners.py.
asyncio.run_coroutine_threadsafe(coro, loop)  
Submit a coroutine to the given event loop. Thread-safe. Return a concurrent.futures.Future to wait for the result from another OS thread. This function is meant to be called from a different OS thread than the one where the event loop is running. Example: # Create a coroutine
coro = asyncio.sleep(1, result=3)

# Submit the coroutine to a given loop
future = asyncio.run_coroutine_threadsafe(coro, loop)

# Wait for the result with an optional timeout argument
assert future.result(timeout) == 3
 If an exception is raised in the coroutine, the returned Future will be notified. It can also be used to cancel the task in the event loop: try:
    result = future.result(timeout)
except asyncio.TimeoutError:
    print('The coroutine took too long, cancelling the task...')
    future.cancel()
except Exception as exc:
    print(f'The coroutine raised an exception: {exc!r}')
else:
    print(f'The coroutine returned: {result!r}')
 See the concurrency and multithreading section of the documentation. Unlike other asyncio functions this function requires the loop argument to be passed explicitly.  New in version 3.5.1.
class asyncio.SafeChildWatcher  
This implementation uses active event loop from the main thread to handle SIGCHLD signal. If the main thread has no running event loop another thread cannot spawn a subprocess (RuntimeError is raised). The watcher avoids disrupting other code spawning processes by polling every process explicitly on a SIGCHLD signal. This solution is as safe as MultiLoopChildWatcher and has the same O(N) complexity but requires a running event loop in the main thread to work.
class asyncio.SelectorEventLoop  
An event loop based on the selectors module. Uses the most efficient selector available for the given platform. It is also possible to manually configure the exact selector implementation to be used: import asyncio
import selectors

selector = selectors.SelectSelector()
loop = asyncio.SelectorEventLoop(selector)
asyncio.set_event_loop(loop)
 Availability: Unix, Windows.
class asyncio.Semaphore(value=1, *, loop=None)  
A Semaphore object. Not thread-safe. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some task calls release(). The optional value argument gives the initial value for the internal counter (1 by default). If the given value is less than 0 a ValueError is raised.  Deprecated since version 3.8, will be removed in version 3.10: The loop parameter.  The preferred way to use a Semaphore is an async with statement: sem = asyncio.Semaphore(10)

# ... later
async with sem:
    # work with shared resource
 which is equivalent to: sem = asyncio.Semaphore(10)

# ... later
await sem.acquire()
try:
    # work with shared resource
finally:
    sem.release()
  
coroutine acquire()  
Acquire a semaphore. If the internal counter is greater than zero, decrement it by one and return True immediately. If it is zero, wait until a release() is called and return True. 
  
locked()  
Returns True if semaphore can not be acquired immediately. 
  
release()  
Release a semaphore, incrementing the internal counter by one. Can wake up a task waiting to acquire the semaphore. Unlike BoundedSemaphore, Semaphore allows making more release() calls than acquire() calls.