U vi @sddlZddlmZddlmZmZmZmZddlmZm Z ddl m Z edZ d eegdfee j eee gdfdd d Zd gZdS) N)Future)CallableOptionalTypeVarcast) Observableabc)SequenceContainsNoElementsError_T Future[_T]) future_ctor schedulerreturncs2|p tj}|ttddfdd }|S)Nr )sourcercsldttdtdfdd }tdfdd }fd d }|j|||d fd d S)a.Converts an existing observable sequence to a Future. If the observable emits a single item, then this item is set as the result of the future. If the observable emits a sequence of items, then the last emitted item is set as the result of the future. Example: future = reactivex.return_value(42).pipe(ops.to_future(asyncio.Future)) Args: future_ctor: [Optional] The constructor of the future. Returns: A future with the last value from the observable sequence. FNvaluecs |ddS)NTr) has_value last_valuerN/opt/alt/python38/lib/python3.8/site-packages/reactivex/operators/_tofuture.pyon_next(sz.to_future_..to_future..on_nexterrcss|dSN) cancelled set_exceptionr)futurerron_error.sz/to_future_..to_future..on_errorcs,s$rn tddSr)r set_resultrr r)rrrrr on_completed2s   z3to_future_..to_future..on_completed)r csSr)Zdispose)_)disrr<z/to_future_..to_future..)rr Exception subscribeadd_done_callback)rrrrrr )r!rrr to_futures  zto_future_..to_future)asyncioget_event_loop create_futurerr )r r Z future_ctor_r(rr'r to_future_ s  ,r,)NN)r)rtypingrrrrZ reactivexrrZreactivex.internal.exceptionsr r Z SchedulerBaser,__all__rrrrs   8