PacktPublishing/Learning-Concurrency-in-Python

Chapter 1. rxPySample.py doesnt work - i fixed it

Opened this issue · 0 comments

As rx library has updated the code should be:
import rx

class temperatureObserver():

def on_next(self, x):
print("Temperature is: %s degrees centigrade" % x)
if (x > 6):
print("Warning: Temperate Is Exceeding Recommended Limit")
if (x == 9):
print("DataCenter is shutting down. Temperature is too high")
def on_error(self, e):
print("Error: %s" % e)

def on_completed(self):
print("All Temps Read")

xs = rx.from_iterable(range(10))
d = xs.subscribe(temperatureObserver())