Skip to content

Commit

Permalink
GObject timeout: use timeout_add and timeout_add_seconds properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Caloto committed Jul 1, 2016
1 parent 089a3a4 commit 85db813
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion galicaster/plugins/forcedurationrec.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create_timer(sender=None, mp_id=None):
global timeout_id
do_stop_timers()
logger.debug("Init a timer to stop a record in {} minutes".format(max_duration))
timeout_id = GObject.timeout_add(60 * max_duration* 1000, stop_recording)
timeout_id = GObject.timeout_add_seconds(60 * max_duration, stop_recording)


def stop_recording(sender=None):
Expand Down
6 changes: 3 additions & 3 deletions galicaster/scheduler/heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def __init__(self, dispatcher, interval_short=10, interval_long=60, nighty_time=


def init_timer(self):
timeout_id = GObject.timeout_add(self.get_seg_until_next()*1000, self.__notify_timer_daily)
timeout_id = GObject.timeout_add(self.interval_short*1000, self.__notify_timer_short)
timeout_id = GObject.timeout_add(self.interval_long*1000, self.__notify_timer_long)
timeout_id = GObject.timeout_add_seconds(self.get_seg_until_next(), self.__notify_timer_daily)
timeout_id = GObject.timeout_add_seconds(self.interval_short, self.__notify_timer_short)
timeout_id = GObject.timeout_add_seconds(self.interval_long, self.__notify_timer_long)


def get_seg_until_next(self):
Expand Down
4 changes: 2 additions & 2 deletions galicaster/scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def create_timer(self, mp):
self.logger.info('Create timer for MP {}, it starts at {}'.format(mp.getIdentifier(), mp.getStartDateAsString()))
self.dispatcher.emit('recorder-scheduled-event', mp.getIdentifier())

timeout_id = GObject.timeout_add(diff.seconds*1000, self.__start_record, mp.getIdentifier())
timeout_id = GObject.timeout_add_seconds(diff.seconds, self.__start_record, mp.getIdentifier())
self.start_timers[mp.getIdentifier()] = timeout_id


Expand Down Expand Up @@ -103,7 +103,7 @@ def __start_record(self, key):

self.logger.info('Start record %s, duration %s ms', mp.getIdentifier(), mp.getDuration())

timeout_id = GObject.timeout_add(mp.getDuration(), self.__stop_record, mp.getIdentifier())
timeout_id = GObject.timeout_add_seconds(mp.getDuration()/1000, self.__stop_record, mp.getIdentifier())
self.recorder.record(mp)

del self.start_timers[mp.getIdentifier()]
Expand Down
2 changes: 1 addition & 1 deletion tests/core/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_connect_ui_and_emit(self):
dispatcher.connect_ui('pr', self.callback_ui)
obj = {'called': False}

timeout_id = GObject.timeout_add(1.0, self.emit_signal, dispatcher, 'pr', obj)
timeout_id = GObject.timeout_add_seconds(1, self.emit_signal, dispatcher, 'pr', obj)
Gtk.main()
self.assertTrue(called)

Expand Down

0 comments on commit 85db813

Please sign in to comment.