Hi, I have my webapp where I have a Mojo::IOLoop->recurring(10 => sub { # relaoding from db }) running (inside the app in the background, not really handling any web request) that reloads some configuration from the database.
When I want to do testing, I want to insert a testing entry in the database, and then run some testing code. But it does not work if I do,
#
# insert some test artifact to the database
#
Mojo::IOLoop->timer(15 => sub { print "done waiting for database reload" });
Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
#
# some cleanup code
#
done_testing;
I saw that the whole thing just keep on going without running the cleanup code (the reloading keeps running). So I think the Mojo::IOLoop is the singleton and since the recurring timer is still active, it just keeps on running. What is the proper way to make it working? Any ideas are appreciated.
Daniel.