summaryrefslogtreecommitdiff
path: root/src/timed_events.py
diff options
context:
space:
mode:
authorFlorent Le Coz <florent.le-coz@epitech.eu>2011-04-08 16:36:00 +0200
committerFlorent Le Coz <florent.le-coz@epitech.eu>2011-04-08 16:36:00 +0200
commit27a20b349cf1975cd75b3d9bc61155ed58ce01d0 (patch)
tree2e8594c2a5b4310ef2e0c3f66fd3c6407d090f76 /src/timed_events.py
parent36daddfaf24c0d91612f6b9ae43a3082be78e46e (diff)
downloadpoezio-27a20b349cf1975cd75b3d9bc61155ed58ce01d0.tar.gz
poezio-27a20b349cf1975cd75b3d9bc61155ed58ce01d0.tar.bz2
poezio-27a20b349cf1975cd75b3d9bc61155ed58ce01d0.tar.xz
poezio-27a20b349cf1975cd75b3d9bc61155ed58ce01d0.zip
Have a timeout in read_char to enable timed events
Diffstat (limited to 'src/timed_events.py')
-rw-r--r--src/timed_events.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/timed_events.py b/src/timed_events.py
new file mode 100644
index 00000000..6e4da396
--- /dev/null
+++ b/src/timed_events.py
@@ -0,0 +1,28 @@
+# Copyright 2010-2011 Le Coz Florent <louiz@louiz.org>
+#
+# This file is part of Poezio.
+#
+# Poezio is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3 of the License.
+#
+# Poezio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Poezio. If not, see <http://www.gnu.org/licenses/>.
+
+
+class TimedEvent(object):
+ """
+ An event with a callback that is called when the specified time is passed
+ Note that these events can NOT be used for very small delay or a very
+ precise date, since the check for events is done once per second, as
+ a maximum
+ """
+ def __init__(self, callback, *args, **kwargs):
+ self._callback = callback
+ self.args = args
+