o Sb"@s,UdZddlmZmZmZmZgdZdZ dZ dZ dZ dZ d Z d Z eeeefd fed <d efddZeZeed<eZ ddlmZddlmZddlmZmZddlmZddlmZddlm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&ddl'm(Z(ddl)m*Z*d e+fddZ,dee-d efddZ.dS)zPython driver for MongoDB.)ContextManagerOptionalTupleUnion) ASCENDING DESCENDINGGEO2D GEOSPHEREHASHEDTEXT version_tupleget_version_string __version__versionReturnDocumentMAX_SUPPORTED_WIRE_VERSIONMIN_SUPPORTED_WIRE_VERSION CursorType MongoClient DeleteMany DeleteOne IndexModel InsertOne ReplaceOne UpdateMany UpdateOneReadPreference WriteConcernhas_ctimeoutZ2dZ2dspherehashedtext)r.r returncCs>ttdtrdtttddtdSdtttS)Nr!.) isinstancer strjoinmapr,r,7/tmp/pip-target-onvjaxws/lib/python/pymongo/__init__.pyr Zs r r)_csot)r)rr)r)r)rrrrrrr)r)rcCs(z ddlm}WdStyYdSw)zIs the C extension installed?r _cmessageTF)pymongor0 ImportErrorr/r,r,r-rws   rsecondscCsJt|tttdfstd|r|dkrtd|dur t|}t|S)a**(Provisional)** Apply the given timeout for a block of operations. .. note:: :func:`~pymongo.timeout` is currently provisional. Backwards incompatible changes may occur before becoming officially supported. Use :func:`~pymongo.timeout` in a with-statement:: with pymongo.timeout(5): client.db.coll.insert_one({}) client.db.coll2.insert_one({}) When the with-statement is entered, a deadline is set for the entire block. When that deadline is exceeded, any blocking pymongo operation will raise a timeout exception. For example:: try: with pymongo.timeout(5): client.db.coll.insert_one({}) time.sleep(5) # The deadline has now expired, the next operation will raise # a timeout exception. client.db.coll2.insert_one({}) except PyMongoError as exc: if exc.timeout: print(f"block timed out: {exc!r}") else: print(f"failed with non-timeout error: {exc!r}") When nesting :func:`~pymongo.timeout`, the newly computed deadline is capped to at most the existing deadline. The deadline can only be shortened, not extended. When exiting the block, the previous deadline is restored:: with pymongo.timeout(5): coll.find_one() # Uses the 5 second deadline. with pymongo.timeout(3): coll.find_one() # Uses the 3 second deadline. coll.find_one() # Uses the original 5 second deadline. with pymongo.timeout(10): coll.find_one() # Still uses the original 5 second deadline. coll.find_one() # Uses the original 5 second deadline. :Parameters: - `seconds`: A non-negative floating point number expressing seconds, or None. :Raises: - :py:class:`ValueError`: When `seconds` is negative. .. versionadded:: 4.2 Nz(timeout must be None, an int, or a floatrztimeout cannot be negative)r(intfloattype TypeError ValueErrorr.Z_TimeoutContext)r3r,r,r-rs2  rN)/__doc__typingrrrr__all__rrrr r r r r4r)__annotations__r rrr1r.Zpymongo.collectionrZpymongo.commonrrZpymongo.cursorrZpymongo.mongo_clientrZpymongo.operationsrrrrrrrZpymongo.read_preferencesrZpymongo.write_concernrboolrr5rr,r,r,r-s<     $