Skip to content

Commit

Permalink
[loop] RunMode → RunModes
Browse files Browse the repository at this point in the history
  • Loading branch information
koehlma committed Dec 29, 2015
1 parent 4daedfe commit e2d9c00
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
11 changes: 11 additions & 0 deletions doc/source/loop.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.. _Loop:

.. currentmodule:: uv

Loop -- event loop
==================

.. autoclass:: uv.Loop
:members:
:member-order: bysource

2 changes: 1 addition & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
self.stop()
return True

def run(self, mode=uv.RunMode.DEFAULT):
def run(self, mode=uv.RunModes.DEFAULT):
self.exc_type = None
result = super(TestLoop, self).run(mode)
if self.exc_type is not None:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def on_prepare(prepare):
for _ in range(500):
self.prepare = uv.Prepare(on_prepare=on_prepare)
self.prepare.start()
self.loop.run(uv.RunMode.ONCE)
self.loop.run(uv.RunModes.ONCE)

self.assert_equal(self.callback_called, 500)

Expand All @@ -62,7 +62,7 @@ def on_timeout(timer):
self.timer = uv.Timer(on_timeout=on_timeout)
self.timer.start(100, repeat=100)

self.loop.run(uv.RunMode.NOWAIT)
self.loop.run(uv.RunModes.NOWAIT)

self.assert_false(self.callback_called)

Expand Down Expand Up @@ -108,7 +108,7 @@ def on_prepare(prepare):
self.loop.run()
self.assert_equal(self.timer_called, 2)
self.assert_greater_equal(self.prepare_called, 2)
self.loop.run(uv.RunMode.NOWAIT)
self.loop.run(uv.RunModes.NOWAIT)
self.assert_greater_equal(self.prepare_called, 3)
self.loop.run()
self.assert_equal(self.timer_called, 10)
Expand Down
2 changes: 1 addition & 1 deletion uv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

from .error import UVError, HandleClosedError, LoopClosedError, StatusCode
from .handle import Handle
from .loop import RunMode, Loop
from .loop import RunModes, Loop
from .request import Request

from .handles.async import *
Expand Down
6 changes: 3 additions & 3 deletions uv/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
from . import common, error, library
from .library import ffi, lib

__all__ = ['RunMode', 'Loop']
__all__ = ['RunModes', 'Loop']


class RunMode(common.Enumeration):
class RunModes(common.Enumeration):
DEFAULT = lib.UV_RUN_DEFAULT
ONCE = lib.UV_RUN_ONCE
NOWAIT = lib.UV_RUN_NOWAIT
Expand Down Expand Up @@ -246,7 +246,7 @@ def get_timeout(self):
if self.closed: raise error.LoopClosedError()
return lib.uv_backend_timeout(self.uv_loop)

def run(self, mode=RunMode.DEFAULT):
def run(self, mode=RunModes.DEFAULT):
if self.closed: raise error.LoopClosedError()
self.make_current()
result = bool(lib.uv_run(self.uv_loop, mode))
Expand Down

0 comments on commit e2d9c00

Please sign in to comment.