# "sample" an agent every second?

**URL:** <https://forum.elixirforum.com/t/sample-an-agent-every-second/37367>\
**Category:** Questions\
**Tags:** agent\
**Created:** [February 6, 2021, 5:57pm UTC](https://forum.elixirforum.com/t/sample-an-agent-every-second/37367 "2021-02-06T17:57:06Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![derek-zhou](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/derek-zhou/32/19943_2.png) [@derek-zhou](https://forum.elixirforum.com/u/derek-zhou)\
**Post date:** [February 7, 2021, 4:57am UTC](https://forum.elixirforum.com/t/sample-an-agent-every-second/37367/6 "2021-02-07T04:57:10Z")

</div>

Since you are already using a PubSub, why don’t you just broadcast from the first GenServer every second using a different topic and let whatever interested party subscribe to it.

If you have to do polling, I’d skip GenServer, timer, sending yourself a message, etc, in the poller altogether, and just spawn off a plain process that sleeps periodically.

---

_[View the full topic](https://forum.elixirforum.com/t/sample-an-agent-every-second/37367)._
