neulab/docprompting-conala huggingface dataset:
socket.sendmsg_afalg([msg, ]*, op[, iv[, assoclen[, flags]]])  
Specialized version of sendmsg() for AF_ALG socket. Set mode, IV, AEAD associated data length and flags for AF_ALG socket. Availability: Linux >= 2.6.38.  New in version 3.6.
socket.sendto(bytes, address)  
socket.sendto(bytes, flags, address)  
Send data to the socket. The socket should not be connected to a remote socket, since the destination socket is specified by address. The optional flags argument has the same meaning as for recv() above. Return the number of bytes sent. (The format of address depends on the address family — see above.) Raises an auditing event socket.sendto with arguments self, address.  Changed in version 3.5: If the system call is interrupted and the signal handler does not raise an exception, the method now retries the system call instead of raising an InterruptedError exception (see PEP 475 for the rationale).
socket.setblocking(flag)  
Set blocking or non-blocking mode of the socket: if flag is false, the socket is set to non-blocking, else to blocking mode. This method is a shorthand for certain settimeout() calls:  
sock.setblocking(True) is equivalent to sock.settimeout(None)
 
sock.setblocking(False) is equivalent to sock.settimeout(0.0)
   Changed in version 3.7: The method no longer applies SOCK_NONBLOCK flag on socket.type.
socket.settimeout(value)  
Set a timeout on blocking socket operations. The value argument can be a nonnegative floating point number expressing seconds, or None. If a non-zero value is given, subsequent socket operations will raise a timeout exception if the timeout period value has elapsed before the operation has completed. If zero is given, the socket is put in non-blocking mode. If None is given, the socket is put in blocking mode. For further information, please consult the notes on socket timeouts.  Changed in version 3.7: The method no longer toggles SOCK_NONBLOCK flag on socket.type.
socket.set_inheritable(inheritable)  
Set the inheritable flag of the socket’s file descriptor or socket’s handle.  New in version 3.4.
socket.share(process_id)  
Duplicate a socket and prepare it for sharing with a target process. The target process must be provided with process_id. The resulting bytes object can then be passed to the target process using some form of interprocess communication and the socket can be recreated there using fromshare(). Once this method has been called, it is safe to close the socket since the operating system has already duplicated it for the target process. Availability: Windows.  New in version 3.3.
socket.shutdown(how)  
Shut down one or both halves of the connection. If how is SHUT_RD, further receives are disallowed. If how is SHUT_WR, further sends are disallowed. If how is SHUT_RDWR, further sends and receives are disallowed.
socket.socketpair([family[, type[, proto]]])  
Build a pair of connected socket objects using the given address family, socket type, and protocol number. Address family, socket type, and protocol number are as for the socket() function above. The default family is AF_UNIX if defined on the platform; otherwise, the default is AF_INET. The newly created sockets are non-inheritable.  Changed in version 3.2: The returned socket objects now support the whole socket API, rather than a subset.   Changed in version 3.4: The returned sockets are now non-inheritable.   Changed in version 3.5: Windows support added.
socket.SocketType  
This is a Python type object that represents the socket object type. It is the same as type(socket(...)).
socket.SOCK_CLOEXEC  
socket.SOCK_NONBLOCK  
These two constants, if defined, can be combined with the socket types and allow you to set some flags atomically (thus avoiding possible race conditions and the need for separate calls).  See also Secure File Descriptor Handling for a more thorough explanation.  Availability: Linux >= 2.6.27.  New in version 3.2.
socket.SOCK_STREAM  
socket.SOCK_DGRAM  
socket.SOCK_RAW  
socket.SOCK_RDM  
socket.SOCK_SEQPACKET  
These constants represent the socket types, used for the second argument to socket(). More constants may be available depending on the system. (Only SOCK_STREAM and SOCK_DGRAM appear to be generally useful.)
SO_*  
socket.SOMAXCONN  
MSG_*  
SOL_*  
SCM_*  
IPPROTO_*  
IPPORT_*  
INADDR_*  
IP_*  
IPV6_*  
EAI_*  
AI_*  
NI_*  
TCP_*  
Many constants of these forms, documented in the Unix documentation on sockets and/or the IP protocol, are also defined in the socket module. They are generally used in arguments to the setsockopt() and getsockopt() methods of socket objects. In most cases, only those symbols that are defined in the Unix header files are defined; for a few symbols, default values are provided.  Changed in version 3.6: SO_DOMAIN, SO_PROTOCOL, SO_PEERSEC, SO_PASSSEC, TCP_USER_TIMEOUT, TCP_CONGESTION were added.   Changed in version 3.6.5: On Windows, TCP_FASTOPEN, TCP_KEEPCNT appear if run-time Windows supports.   Changed in version 3.7: TCP_NOTSENT_LOWAT was added. On Windows, TCP_KEEPIDLE, TCP_KEEPINTVL appear if run-time Windows supports.
exception socket.timeout  
A subclass of OSError, this exception is raised when a timeout occurs on a socket which has had timeouts enabled via a prior call to settimeout() (or implicitly through setdefaulttimeout()). The accompanying value is a string whose value is currently always “timed out”.  Changed in version 3.3: This class was made a subclass of OSError.
class socketserver.BaseRequestHandler  
This is the superclass of all request handler objects. It defines the interface, given below. A concrete request handler subclass must define a new handle() method, and can override any of the other methods. A new instance of the subclass is created for each request.  
setup()  
Called before the handle() method to perform any initialization actions required. The default implementation does nothing. 
  
handle()  
This function must do all the work required to service a request. The default implementation does nothing. Several instance attributes are available to it; the request is available as self.request; the client address as self.client_address; and the server instance as self.server, in case it needs access to per-server information. The type of self.request is different for datagram or stream services. For stream services, self.request is a socket object; for datagram services, self.request is a pair of string and socket. 
  
finish()  
Called after the handle() method to perform any clean-up actions required. The default implementation does nothing. If setup() raises an exception, this function will not be called.
finish()  
Called after the handle() method to perform any clean-up actions required. The default implementation does nothing. If setup() raises an exception, this function will not be called.
handle()  
This function must do all the work required to service a request. The default implementation does nothing. Several instance attributes are available to it; the request is available as self.request; the client address as self.client_address; and the server instance as self.server, in case it needs access to per-server information. The type of self.request is different for datagram or stream services. For stream services, self.request is a socket object; for datagram services, self.request is a pair of string and socket.
setup()  
Called before the handle() method to perform any initialization actions required. The default implementation does nothing.
address_family  
The family of protocols to which the server’s socket belongs. Common examples are socket.AF_INET and socket.AF_UNIX.
allow_reuse_address  
Whether the server will allow the reuse of an address. This defaults to False, and can be set in subclasses to change the policy.
fileno()  
Return an integer file descriptor for the socket on which the server is listening. This function is most commonly passed to selectors, to allow monitoring multiple servers in the same process.
finish_request(request, client_address)  
Actually processes the request by instantiating RequestHandlerClass and calling its handle() method.
get_request()  
Must accept a request from the socket, and return a 2-tuple containing the new socket object to be used to communicate with the client, and the client’s address.
handle_error(request, client_address)  
This function is called if the handle() method of a RequestHandlerClass instance raises an exception. The default action is to print the traceback to standard error and continue handling further requests.  Changed in version 3.6: Now only called for exceptions derived from the Exception class.
handle_request()  
Process a single request. This function calls the following methods in order: get_request(), verify_request(), and process_request(). If the user-provided handle() method of the handler class raises an exception, the server’s handle_error() method will be called. If no request is received within timeout seconds, handle_timeout() will be called and handle_request() will return.
handle_timeout()  
This function is called when the timeout attribute has been set to a value other than None and the timeout period has passed with no requests being received. The default action for forking servers is to collect the status of any child processes that have exited, while in threading servers this method does nothing.
process_request(request, client_address)  
Calls finish_request() to create an instance of the RequestHandlerClass. If desired, this function can create a new process or thread to handle the request; the ForkingMixIn and ThreadingMixIn classes do this.
RequestHandlerClass  
The user-provided request handler class; an instance of this class is created for each request.
request_queue_size  
The size of the request queue. If it takes a long time to process a single request, any requests that arrive while the server is busy are placed into a queue, up to request_queue_size requests. Once the queue is full, further requests from clients will get a “Connection denied” error. The default value is usually 5, but this can be overridden by subclasses.
server_activate()  
Called by the server’s constructor to activate the server. The default behavior for a TCP server just invokes listen() on the server’s socket. May be overridden.
server_address  
The address on which the server is listening. The format of addresses varies depending on the protocol family; see the documentation for the socket module for details. For Internet protocols, this is a tuple containing a string giving the address, and an integer port number: ('127.0.0.1', 80), for example.
server_bind()  
Called by the server’s constructor to bind the socket to the desired address. May be overridden.
serve_forever(poll_interval=0.5)  
Handle requests until an explicit shutdown() request. Poll for shutdown every poll_interval seconds. Ignores the timeout attribute. It also calls service_actions(), which may be used by a subclass or mixin to provide actions specific to a given service. For example, the ForkingMixIn class uses service_actions() to clean up zombie child processes.  Changed in version 3.3: Added service_actions call to the serve_forever method.
service_actions()  
This is called in the serve_forever() loop. This method can be overridden by subclasses or mixin classes to perform actions specific to a given service, such as cleanup actions.  New in version 3.3.
shutdown()  
Tell the serve_forever() loop to stop and wait until it does. shutdown() must be called while serve_forever() is running in a different thread otherwise it will deadlock.
socket_type  
The type of socket used by the server; socket.SOCK_STREAM and socket.SOCK_DGRAM are two common values.
timeout  
Timeout duration, measured in seconds, or None if no timeout is desired. If handle_request() receives no incoming requests within the timeout period, the handle_timeout() method is called.
verify_request(request, client_address)  
Must return a Boolean value; if the value is True, the request will be processed, and if it’s False, the request will be denied. This function can be overridden to implement access controls for a server. The default implementation always returns True.
class socketserver.StreamRequestHandler  
class socketserver.DatagramRequestHandler  
These BaseRequestHandler subclasses override the setup() and finish() methods, and provide self.rfile and self.wfile attributes. The self.rfile and self.wfile attributes can be read or written, respectively, to get the request data or return data to the client. The rfile attributes of both classes support the io.BufferedIOBase readable interface, and DatagramRequestHandler.wfile supports the io.BufferedIOBase writable interface.  Changed in version 3.6: StreamRequestHandler.wfile also supports the io.BufferedIOBase writable interface.
class socketserver.ForkingMixIn  
class socketserver.ThreadingMixIn  
Forking and threading versions of each type of server can be created using these mix-in classes. For instance, ThreadingUDPServer is created as follows: class ThreadingUDPServer(ThreadingMixIn, UDPServer):
    pass
 The mix-in class comes first, since it overrides a method defined in UDPServer. Setting the various attributes also changes the behavior of the underlying server mechanism. ForkingMixIn and the Forking classes mentioned below are only available on POSIX platforms that support fork(). socketserver.ForkingMixIn.server_close() waits until all child processes complete, except if socketserver.ForkingMixIn.block_on_close attribute is false. socketserver.ThreadingMixIn.server_close() waits until all non-daemon threads complete, except if socketserver.ThreadingMixIn.block_on_close attribute is false. Use daemonic threads by setting ThreadingMixIn.daemon_threads to True to not wait until threads complete.  Changed in version 3.7: socketserver.ForkingMixIn.server_close() and socketserver.ThreadingMixIn.server_close() now waits until all child processes and non-daemonic threads complete. Add a new socketserver.ForkingMixIn.block_on_close class attribute to opt-in for the pre-3.7 behaviour.
class socketserver.ForkingTCPServer  
class socketserver.ForkingUDPServer  
class socketserver.ThreadingTCPServer  
class socketserver.ThreadingUDPServer  
These classes are pre-defined using the mix-in classes.
class socketserver.TCPServer(server_address, RequestHandlerClass, bind_and_activate=True)  
This uses the Internet TCP protocol, which provides for continuous streams of data between the client and server. If bind_and_activate is true, the constructor automatically attempts to invoke server_bind() and server_activate(). The other parameters are passed to the BaseServer base class.
class socketserver.UDPServer(server_address, RequestHandlerClass, bind_and_activate=True)  
This uses datagrams, which are discrete packets of information that may arrive out of order or be lost while in transit. The parameters are the same as for TCPServer.
class socketserver.UnixStreamServer(server_address, RequestHandlerClass, bind_and_activate=True)  
class socketserver.UnixDatagramServer(server_address, RequestHandlerClass, bind_and_activate=True)  
These more infrequently used classes are similar to the TCP and UDP classes, but use Unix domain sockets; they’re not available on non-Unix platforms. The parameters are the same as for TCPServer.
sorted(iterable, *, key=None, reverse=False)  
Return a new sorted list from the items in iterable. Has two optional arguments which must be specified as keyword arguments. key specifies a function of one argument that is used to extract a comparison key from each element in iterable (for example, key=str.lower). The default value is None (compare the elements directly). reverse is a boolean value. If set to True, then the list elements are sorted as if each comparison were reversed. Use functools.cmp_to_key() to convert an old-style cmp function to a key function. The built-in sorted() function is guaranteed to be stable. A sort is stable if it guarantees not to change the relative order of elements that compare equal — this is helpful for sorting in multiple passes (for example, sort by department, then by salary grade). For sorting examples and a brief sorting tutorial, see Sorting HOW TO.
spwd — The shadow password database This module provides access to the Unix shadow password database. It is available on various Unix versions. You must have enough privileges to access the shadow password database (this usually means you have to be root). Shadow password database entries are reported as a tuple-like object, whose attributes correspond to the members of the spwd structure (Attribute field below, see <shadow.h>):   
Index Attribute Meaning   
0 sp_namp Login name  
1 sp_pwdp Encrypted password  
2 sp_lstchg Date of last change  
3 sp_min Minimal number of days between changes  
4 sp_max Maximum number of days between changes  
5 sp_warn Number of days before password expires to warn user about it  
6 sp_inact Number of days after password expires until account is disabled  
7 sp_expire Number of days since 1970-01-01 when account expires  
8 sp_flag Reserved   The sp_namp and sp_pwdp items are strings, all others are integers. KeyError is raised if the entry asked for cannot be found. The following functions are defined:  
spwd.getspnam(name)  
Return the shadow password database entry for the given user name.  Changed in version 3.6: Raises a PermissionError instead of KeyError if the user doesn’t have privileges.  
  
spwd.getspall()  
Return a list of all available shadow password database entries, in arbitrary order. 
  See also  
Module grp


An interface to the group database, similar to this.  
Module pwd


An interface to the normal password database, similar to this.
spwd.getspall()  
Return a list of all available shadow password database entries, in arbitrary order.
spwd.getspnam(name)  
Return the shadow password database entry for the given user name.  Changed in version 3.6: Raises a PermissionError instead of KeyError if the user doesn’t have privileges.
sqlite3.complete_statement(sql)  
Returns True if the string sql contains one or more complete SQL statements terminated by semicolons. It does not verify that the SQL is syntactically correct, only that there are no unclosed string literals and the statement is terminated by a semicolon. This can be used to build a shell for SQLite, as in the following example: # A minimal SQLite shell for experiments

import sqlite3

con = sqlite3.connect(":memory:")
con.isolation_level = None
cur = con.cursor()

buffer = ""

print("Enter your SQL commands to execute in sqlite3.")
print("Enter a blank line to exit.")

while True:
    line = input()
    if line == "":
        break
    buffer += line
    if sqlite3.complete_statement(buffer):
        try:
            buffer = buffer.strip()
            cur.execute(buffer)

            if buffer.lstrip().upper().startswith("SELECT"):
                print(cur.fetchall())
        except sqlite3.Error as e:
            print("An error occurred:", e.args[0])
        buffer = ""

con.close()
sqlite3.connect(database[, timeout, detect_types, isolation_level, check_same_thread, factory, cached_statements, uri])  
Opens a connection to the SQLite database file database. By default returns a Connection object, unless a custom factory is given. database is a path-like object giving the pathname (absolute or relative to the current working directory) of the database file to be opened. You can use ":memory:" to open a database connection to a database that resides in RAM instead of on disk. When a database is accessed by multiple connections, and one of the processes modifies the database, the SQLite database is locked until that transaction is committed. The timeout parameter specifies how long the connection should wait for the lock to go away until raising an exception. The default for the timeout parameter is 5.0 (five seconds). For the isolation_level parameter, please see the isolation_level property of Connection objects. SQLite natively supports only the types TEXT, INTEGER, REAL, BLOB and NULL. If you want to use other types you must add support for them yourself. The detect_types parameter and the using custom converters registered with the module-level register_converter() function allow you to easily do that. detect_types defaults to 0 (i. e. off, no type detection), you can set it to any combination of PARSE_DECLTYPES and PARSE_COLNAMES to turn type detection on. Due to SQLite behaviour, types can’t be detected for generated fields (for example max(data)), even when detect_types parameter is set. In such case, the returned type is str. By default, check_same_thread is True and only the creating thread may use the connection. If set False, the returned connection may be shared across multiple threads. When using multiple threads with the same connection writing operations should be serialized by the user to avoid data corruption. By default, the sqlite3 module uses its Connection class for the connect call. You can, however, subclass the Connection class and make connect() use your class instead by providing your class for the factory parameter. Consult the section SQLite and Python types of this manual for details. The sqlite3 module internally uses a statement cache to avoid SQL parsing overhead. If you want to explicitly set the number of statements that are cached for the connection, you can set the cached_statements parameter. The currently implemented default is to cache 100 statements. If uri is true, database is interpreted as a URI. This allows you to specify options. For example, to open a database in read-only mode you can use: db = sqlite3.connect('file:path/to/database?mode=ro', uri=True)
 More information about this feature, including a list of recognized options, can be found in the SQLite URI documentation. Raises an auditing event sqlite3.connect with argument database.  Changed in version 3.4: Added the uri parameter.   Changed in version 3.7: database can now also be a path-like object, not only a string.
backup(target, *, pages=-1, progress=None, name="main", sleep=0.250)  
This method makes a backup of a SQLite database even while it’s being accessed by other clients, or concurrently by the same connection. The copy will be written into the mandatory argument target, that must be another Connection instance. By default, or when pages is either 0 or a negative integer, the entire database is copied in a single step; otherwise the method performs a loop copying up to pages pages at a time. If progress is specified, it must either be None or a callable object that will be executed at each iteration with three integer arguments, respectively the status of the last iteration, the remaining number of pages still to be copied and the total number of pages. The name argument specifies the database name that will be copied: it must be a string containing either "main", the default, to indicate the main database, "temp" to indicate the temporary database or the name specified after the AS keyword in an ATTACH DATABASE statement for an attached database. The sleep argument specifies the number of seconds to sleep by between successive attempts to backup remaining pages, can be specified either as an integer or a floating point value. Example 1, copy an existing database into another: import sqlite3

def progress(status, remaining, total):
    print(f'Copied {total-remaining} of {total} pages...')

con = sqlite3.connect('existing_db.db')
bck = sqlite3.connect('backup.db')
with bck:
    con.backup(bck, pages=1, progress=progress)
bck.close()
con.close()
 Example 2, copy an existing database into a transient copy: import sqlite3

source = sqlite3.connect('existing_db.db')
dest = sqlite3.connect(':memory:')
source.backup(dest)
 Availability: SQLite 3.6.11 or higher  New in version 3.7.
close()  
This closes the database connection. Note that this does not automatically call commit(). If you just close your database connection without calling commit() first, your changes will be lost!
commit()  
This method commits the current transaction. If you don’t call this method, anything you did since the last call to commit() is not visible from other database connections. If you wonder why you don’t see the data you’ve written to the database, please check you didn’t forget to call this method.