<s> try : <EOL> import asyncio <EOL> except ImportError : <EOL> import trollius as asyncio <EOL> from acouchbase . asyncio_iops import IOPS <EOL> from acouchbase . iterator import AView , AN1QLRequest <EOL> from couchbase . async . bucket import AsyncBucket <EOL> from couchbase . experimental import enabled_or_raise ; enabled_or_raise ( ) <EOL> class Bucket ( AsyncBucket ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> loop = asyncio . get_event_loop ( ) <EOL> super ( Bucket , self ) . __init__ ( IOPS ( loop ) , * args , ** kwargs ) <EOL> self . _loop = loop <EOL> cft = asyncio . Future ( loop = loop ) <EOL> def ftresult ( err ) : <EOL> if err : <EOL> cft . set_exception ( err ) <EOL> else : <EOL> cft . set_result ( True ) <EOL> self . _cft = cft <EOL> self . _conncb = ftresult <EOL> def _meth_factory ( meth , name ) : <EOL> def ret ( self , * args , ** kwargs ) : <EOL> rv = meth ( self , * args , ** kwargs ) <EOL> ft = asyncio . Future ( ) <EOL> def on_ok ( res ) : <EOL> ft . set_result ( res ) <EOL> rv . clear_callbacks ( ) <EOL> def on_err ( res , excls , excval , exctb ) : <EOL> err = excls ( excval ) <EOL> ft . set_exception ( err ) <EOL> rv . clear_callbacks ( ) <EOL> rv . set_callbacks ( on_ok , on_err ) <EOL> return ft <EOL> return ret <EOL> def query ( self , * args , ** kwargs ) : <EOL> if "<STR_LIT>" not in kwargs : <EOL> kwargs [ "<STR_LIT>" ] = AView <EOL> return super ( ) . query ( * args , ** kwargs ) <EOL> def n1ql_query ( self , * args , ** kwargs ) : <EOL> if "<STR_LIT>" not in kwargs : <EOL> kwargs [ "<STR_LIT>" ] = AN1QLRequest <EOL> return super ( ) . n1ql_query ( * args , ** kwargs ) <EOL> locals ( ) . update ( AsyncBucket . _gen_memd_wrappers ( _meth_factory ) ) <EOL> def connect ( self ) : <EOL> if not self . connected : <EOL> self . _connect ( ) <EOL> return self . _cft </s>
