class SingleThreadedWorker(object):
    def __init__(self, poller):
        self._poller = poller

    def run_forever(self, loop=-1):
        while loop:
            task = self._poller.poll_next_task()
            task()
            loop = max(-1, loop - 1)

@@ -140,19 +140,24 @@
     
-while 
+loop = int(
 loop
-:
+)
 %0A   
@@ -165,18 +165,19 @@
     
-   
+for
  task 
-=
+in
  sel
@@ -189,43 +189,45 @@
 ller
-.poll_next_task()%0A            task(
+:%0A            loop = max(-1, loop - 1
 )%0A  
@@ -236,33 +236,63 @@
         
+if 
 loop =
- max(-1, loop - 1
+= 0:%0A                break%0A            task(
 )%0A

Update worker.