question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Restarting script with interval 0 yields ZeroDivisionError

See original GitHub issue

Describe the bug

Calling self.restart(interval=0, repeats=0, start_delay=False) on a script seems to be resulting in a ZeroDivisionError.

Environment, Evennia version, OS etc

Evennia version: 0.9.0 (rev a27a8c3d)
         OS: posix
         Python: 3.7.6
         Twisted: 19.10.0
         Django: 2.2.9

Additional context

20-01-27 20:45:33 Unhandled error in Deferred:
20-01-27 20:45:33 Unhandled Error
        Traceback (most recent call last):
          File "/home/ubuntu/CLOWN/lib/python3.7/site-packages/twisted/internet/defer.py", line 151, in maybeDeferred
            result = f(*args, **kw)
          File "/home/ubuntu/workspace/evennia/evennia/server/amp_client.py", line 236, in server_receive_adminportal2server
            server_sessionhandler.server.shutdown(mode="reload")
          File "/home/ubuntu/CLOWN/lib/python3.7/site-packages/twisted/internet/defer.py", line 1613, in unwindGenerator
            return _cancellableInlineCallbacks(gen)
          File "/home/ubuntu/CLOWN/lib/python3.7/site-packages/twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks
            _inlineCallbacks(None, g, status)
        --- <exception caught here> ---
          File "/home/ubuntu/CLOWN/lib/python3.7/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
            result = g.send(result)
          File "/home/ubuntu/workspace/evennia/evennia/server/server.py", line 418, in shutdown
            for s in ScriptDB.get_all_cached_instances()
          File "/home/ubuntu/workspace/evennia/evennia/server/server.py", line 419, in <listcomp>
            if s.is_active or s.attributes.has("_manual_pause")
          File "/home/ubuntu/workspace/evennia/evennia/scripts/scripts.py", line 517, in pause
            self.db._paused_time = task.next_call_time()
          File "/home/ubuntu/workspace/evennia/evennia/scripts/scripts.py", line 141, in next_call_time
            return interval - (total_runtime % self.interval)
        builtins.ZeroDivisionError: float modulo

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
strikacocommented, Jan 29, 2020

@Oscuro87 Thanks for the quick fix!

2reactions
Oscuro87commented, Jan 28, 2020

Oh right, I’ll adapt to the -1 situation, and yes, I’ll do a PR in the next few minutes!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error python : [ZeroDivisionError: division by zero]
Returning zero instead of the division by zero error can be accomplished with a Boolean operation. z = y ...
Read more >
signal — Set handlers for asynchronous events ... - Python Docs
ZeroDivisionError is raised when the second argument of a division or modulo ... Returns current value of a given interval timer specified by...
Read more >
Python Timer Functions: Three Ways to Monitor Your Code
In this step-by-step tutorial, you'll learn how to use Python timer functions to monitor how quickly your programs are running.
Read more >
Changelog — PyTorch Lightning 1.8.6 documentation
Added a sanity check that scripts are executed with the srun command in SLURM ... Fixed bug where progress bar was not being...
Read more >
Changelog — Dask.distributed 2022.12.1 documentation
Fix bug when restarting client (GH#6654) Iain Dorrington ... has_arg returns True for keyword-only arguments (GH#6648) Lawrence Mitchell.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found