Skip to content

Conversation

@marco97pa
Copy link
Contributor

Replaced all calls to time.clock() with time.perf_counter().

time.clock() has been removed from the time module in Python 3.8.

This PR closes #108 and makes the app executable again on Python 3.8+

Tested on my Windows machine with Python 3.8

Before the fix, the app was crashing unexpectedly with the following Traceback:

  File "main.py", line 902, in <module>
    main()
  File "main.py", line 898, in main
    pyglet.app.run()
  File "C:\Users\***\AppData\Roaming\Python\Python38\site-packages\pyglet\app\__init__.py", line 107, in run
    event_loop.run()
  File "C:\Users\***\AppData\Roaming\Python\Python38\site-packages\pyglet\app\base.py", line 167, in run
    timeout = self.idle()
  File "C:\Users\***\AppData\Roaming\Python\Python38\site-packages\pyglet\app\base.py", line 237, in idle
    redraw_all = self.clock.call_scheduled_functions(dt)
  File "C:\Users\***\AppData\Roaming\Python\Python38\site-packages\pyglet\clock.py", line 292, in call_scheduled_functions
    item.func(now - item.last_ts, *item.args, **item.kwargs)
  File "main.py", line 571, in update
    self.model.process_queue()
  File "main.py", line 422, in process_queue
    start = time.clock()

Replaced all calls to time.clock() with time.perf_counter().

time.clock() has been removed from the time module in Python 3.8.
@fogleman fogleman merged commit e311522 into fogleman:master Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: module 'time' has no attribute 'clock' - Python 3.8

2 participants