U vi:@sddlmZmZmZmZddlmZmZmZddlm Z ddl m Z edZ d ej eejeee gee fddd Zd gZdS) )AnyCallableOptionalTypeVar) Observableabctyping)CompositeDisposable)TimeoutScheduler_TN)duration schedulerreturncs"ttttdfdd }|S)N)sourcercs2dtjtttjtjdfdd }t|S)aTakes elements for the specified duration from the start of the observable source sequence. Example: >>> res = take_with_time(source) This operator accumulates a queue with a length enough to store elements received during the initial duration window. As more elements are received, elements older than the specified duration are taken from the queue and produced on the result sequence. This causes elements to be delayed with duration. Args: source: Source observable to take elements from. Returns: An observable sequence with the elements taken during the specified duration from the start of the source sequence. N)observer scheduler_rcsHp|pt}dtjtdfdd }||}t|j|dS)Nr statecs dS)N)Z on_completedrrR/opt/alt/python38/lib/python3.8/site-packages/reactivex/operators/_takewithtime.pyaction(szJtake_with_time_..take_with_time..subscribe..action)r )N)r Z singletonr SchedulerBaserZschedule_relativer subscribe)rrZ _schedulerrZdisp)r r rrrr"s  z:take_with_time_..take_with_time..subscribe)N)rZ ObserverBaser rrZDisposableBaser)rrr r )rrtake_with_time sz'take_with_time_..take_with_time)rr )r r rrrrtake_with_time_ s%r)N)rrrrrZ reactivexrrZreactivex.disposabler Zreactivex.schedulerr r Z RelativeTimerr__all__rrrrs   +