# Event\_handler is timer based

**URL:** <https://discourse.nameko.io/t/event-handler-is-timer-based/390>\
**Category:** Uncategorized\
**Created:** [January 16, 2019, 7:46pm UTC](https://discourse.nameko.io/t/event-handler-is-timer-based/390 "2019-01-16T19:46:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![coddericko](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/coddericko/32/16_2.png) [@coddericko](https://discourse.nameko.io/u/coddericko)\
**Post date:** [January 16, 2019, 7:46pm UTC](https://discourse.nameko.io/t/event-handler-is-timer-based/390/1 "2019-01-16T19:46:54Z")

</div>

Hi,

Just wonder is there a special directive that we can configure event\_handler to consume message periodically

eg:  
@event\_handler(‘serviceA’,‘queueA’, timer=60s)  
def polling(self, dummy\_data):  
statement a  
result = check\_status()  
if not result:  
self.event\_dispatcher(‘queueA’,{})

As you can see, the event handler will consume one message at a time from queueA every 60 seconds.

Currently, i use this logic, there will be a recursive firing of alot of events till check\_status return false. What we do not want is to implement a database logic in order to support this.

Any help will be useful

---

<div class="post-metadata">

**Author:** ![mattbennett](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/mattbennett/32/13_2.png) [@mattbennett](https://discourse.nameko.io/u/mattbennett)\
**Post date:** [January 16, 2019, 8:07pm UTC](https://discourse.nameko.io/t/event-handler-is-timer-based/390/2 "2019-01-16T20:07:33Z")

</div>

I’m not sure I understand the question.

`event_handler` does not accept a `timer` argument, and it is not possible to do “periodic consumes” – the consumer will grab messages as soon as they are available on the queue.

But there is possibly a way to get the behaviour you want if you restrict your entrypoint to consume a single message at a time (using the `prefetch_count` argument), and an insert a delay in the service method.

```python
class Service:
    
    @event_handler("serviceA", "queueA", prefetch_count=1):
    def poll(self, event_data):
         time.sleep(60)
         print(event_data)

```

This will print the data from an event every 60 seconds.

You need to use the Nameko 3.x prerelease (`pip install --pre nameko`) because the `prefetch_count` argument is only exposed there.

---

<div class="post-metadata">

**Author:** ![coddericko](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/coddericko/32/16_2.png) [@coddericko](https://discourse.nameko.io/u/coddericko)\
**Post date:** [January 17, 2019, 12:34am UTC](https://discourse.nameko.io/t/event-handler-is-timer-based/390/3 "2019-01-17T00:34:33Z")

</div>

Thanks matt… yes, what we need is

> periodic consumes

Sounds like it is not possible for now without create a persistent table/app logic for a internal queue. I tot it would be easier to use rabbit as it is already a queue
