Questions tagged [rx-py]

Reactive Extensions for Python

RxPY is a library for composing asynchronous and event-based programs using observable collections and LINQ-style query operators in Python.

RxPY is open sourced and available under the Apache License, Version 2.0

96 questions
2
votes
1 answer

Python move from imperative to functional in production

I became infected with functional programming and reactive approach. For inspiration and ideas, I use Haskell and an awesome Rick Hickey article. In the python world I found for myself RxPy and funcy libraries. Now I have thousands of lines of…
2
votes
1 answer

RxPy - Turn Live Twitter Stream into Rx Observable?

I followed along this great tutorial to leverage a live Twitter stream in Python using tweepy. This will print Tweets in live time that mention RxJava, RxPy, RxScala, or ReactiveX. from tweepy.streaming import StreamListener from tweepy import…
tmn
  • 11,121
  • 15
  • 56
  • 112
2
votes
1 answer

Observing a button press with RxPY

How can I "listen" to stream of key press events with Python? I want to do something like this: click_stream.map(lambda k: k.key) But how can I create this click_stream?
kharandziuk
  • 12,020
  • 17
  • 63
  • 121
2
votes
2 answers

How to use Reactive Extensions (Rx) LINQ in Python?

I downloaded RxPY and was watching the Rx tutorials when I came across: So how would I get the above working in Python with RxPY? In particular, the query q = from x in xs where... is not syntactically valid Python code -- so how would this be…
mchen
  • 9,808
  • 17
  • 72
  • 125
1
vote
0 answers

RxPY concurrency

I'm trying to understand what operations are serialized and what are not with RxPY. So I printed out thread names and current delay in seconds during map and subscribe calls in the example below. I was expecting the delay in seconds for map…
Shuming
  • 11
  • 2
1
vote
1 answer

How to use subprocess in a RxPY map correctly?

I am trying to use RxPY to scan the IP to see which hosts are up. However, currently it returns empty. For ping(ip), if I simply return ip, it will return a list of IP address. from reactivex import operators as ops import reactivex as rx import…
Hongbo Miao
  • 45,290
  • 60
  • 174
  • 267
1
vote
1 answer

How can I rewrite this countdown timer using RxPY?

Here's RxJS code I'm trying to reproduce with RxPY. const counter$ = interval(1000); counter$ .pipe( mapTo(-1), scan((accumulator, current) => { return accumulator + current; }, 10), takeWhile(value => value >= 0) ) …
melkir
  • 405
  • 1
  • 5
  • 22
1
vote
1 answer

Python: How to call async function inside rx.subject subscribe on_next

I need to call an async function inside the on_next of a python rx subscription as this: from rx.subject import Subject import asyncio async def asyncPrint(value: str): print(f'async print: {value}') async def main(): s = Subject() …
1
vote
1 answer

Why is it taking so long until rx.interval creates any output?

I wanted to create an observable that emits an event at an interval of 100 ms. I tried using rx.interval: import rx tick = rx.interval(100) tick.subscribe(on_next=lambda i: print(i)) The process is not running and gives the disposable as…
Aravind OR
  • 97
  • 2
  • 10
1
vote
1 answer

Using combine_latest with more than 2 observables in RxPy

If I have something like this: scheduler = EventLoopScheduler() obs1 = rx.range(0, 10) obs2 = rx.range(20, 30).pipe(ops.combine_latest(obs1)) obs2.subscribe(lambda it: print(it), scheduler=scheduler) time.sleep(5) It gives me an output…
1
vote
0 answers

how to publish celery state with an observable?

I am building a progress bar application that uses celery for executing async tasks. The task is started with a GraphQL mutation and updates its own state each second: @celery.task(bind=True, name='mock_analyzing') def mock_analyzing(self,…
bulle
  • 51
  • 5
1
vote
1 answer

Can I transpile python 3.7 code to a lower version?

In a python-based project, I would like to use features data classes and libraries such as the current RxPY version. However, we are bound to an environment (a Yocto-system) that only has Python 3.5.5 From TypeScript/JavaScript I know that some…
David Brem
  • 504
  • 2
  • 6
  • 16
1
vote
2 answers

I am getting "AttributeError: type object 'Observable' has no attribute 'from_'" error in python rx=3.0.1

this is code from the "reactive programming with python" book that I have tried on my laptop. import sys from rx import Observable argv = Observable.from_(sys.argv[1:]) argv.subscribe( on_next=lambda i: print("on_next: {}".format(i)), …
1
vote
2 answers

type object 'ObservableBase' has no attribute 'create' RxPy

I am trying to understand how RxPy works, I am getting this error type object 'ObservableBase' has no attribute 'create' I am using python 3.6 and my code is from rx import Observable stocks = [ {'TCKR': 'APPL', 'PRICE': 200}, {'TCKR':…
scionoftech
  • 608
  • 2
  • 9
  • 24
1
vote
0 answers

Determine time frame between mousePress and mouseMove for drag event in RxPy

I am trying to achieve a drag and drop feature. The layout of my UI looks similar to below: --- --- --- | 1 | 2 | | --- --- 5 | | 3 | 4 | | --- --- --- Boxes 1, 2, 3 and 4 are images and will have a white border surrounding it when selected…
eugeneoei
  • 210
  • 3
  • 16