Repository: napari/napari

Issue:
napari  0.4.17 fails with QtPoll error on a virgin install on windows. Works on the nightly build
## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->

## To Reproduce

Steps to reproduce the behavior:

1. I am running the code with Python 3.10.9.
2. Created a new venv to ensure that we don't have any dead dependencies lying around.
3. Ran <b>pip install "napari[pyqt5]" </b> to install the current release version of napari.
4. Attempted to run napari. The code fails with the error stack below. It also fails if I run napari -info. The stack trace is below

<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

(virginpip) C:\Users\agovi>napari -info
Traceback (most recent call last):
  File "C:\Users\agovi\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\agovi\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\agovi\.virtualenvs\virginpip\Scripts\napari.exe\__main__.py", line 7, in <module>
  File "C:\Users\agovi\.virtualenvs\virginpip\lib\site-packages\napari\__main__.py", line 561, in main
    _run()
  File "C:\Users\agovi\.virtualenvs\virginpip\lib\site-packages\napari\__main__.py", line 327, in _run
    viewer = Viewer()
  File "C:\Users\agovi\.virtualenvs\virginpip\lib\site-packages\napari\viewer.py", line 67, in __init__
    self._window = Window(self, show=show)
  File "C:\Users\agovi\.virtualenvs\virginpip\lib\site-packages\napari\_qt\qt_main_window.py", line 463, in __init__
    self._qt_window = _QtMainWindow(viewer)
  File "C:\Users\agovi\.virtualenvs\virginpip\lib\site-packages\napari\_qt\qt_main_window.py", line 88, in __init__
    self._qt_viewer = QtViewer(viewer, show_welcome_screen=True)
  File "C:\Users\agovi\.virtualenvs\virginpip\lib\site-packages\napari\_qt\qt_viewer.py", line 269, in __init__
    self._qt_poll = _create_qt_poll(self, self.viewer.camera)
  File "C:\Users\agovi\.virtualenvs\virginpip\lib\site-packages\napari\_qt\qt_viewer.py", line 1254, in _create_qt_poll
    qt_poll = QtPoll(parent)
  File "C:\Users\agovi\.virtualenvs\virginpip\lib\site-packages\napari\_qt\experimental\qt_poll.py", line 55, in __init__
    self.timer.setInterval(POLL_INTERVAL_MS)
TypeError: setInterval(self, int): argument 1 has unexpected type 'float'


## Expected behavior

<!-- A clear and concise description of what you expected to happen. -->
Expected napari to work correctly. This fails with this version of napari. The previous and the current nightly build are working correctly.  
Have a similar problem with other users. Have included requirements.txt file that I generated with this report. 

## Environment

 - Cannot get the napari up to show the napari info above. Have extracted the napari version from the pip requirements.txt file. 

 - Any other relevant information:

## Additional context

<!-- Add any other context about the problem here. -->
This is on a windows machine. 
[requirements.txt](https://github.com/napari/napari/files/10249367/requirements.txt)



Discussion:
Hmm, I think this is the related to python 3.10 and pyqt5 int conversion:
https://bugs.python.org/issue37999

We have a float:
https://github.com/napari/napari/blob/5e0aebeee62111d2dedeb12b8fe47a5ae77c7326/napari/_qt/experimental/qt_poll.py#L14

But here it should be an int:
https://github.com/napari/napari/blob/5e0aebeee62111d2dedeb12b8fe47a5ae77c7326/napari/_qt/experimental/qt_poll.py#L55

Can you clarify what you mean it works with previous or nightly?

Are you still using python 3.10 and pyqt5 in those cases?
With python 3.9 I think you should avoid the bug. Likewise pyqt6 or pyside6.
On digging deeper, the released code works for python 3.10.8. It fails on 3.10.9 which is the latest version of python released. In trying to keep myself updated to the latest version, upgraded without thinking of the implications on napari. Not a deal breaker, but something which we may want to add in the readme.. 
Whoops. Thats what I get for talking too soon. Had a nightly build of napari lying around. Am going back to the nightly build for now and will look into this deeper. 
AHA! I can replicate it!
You have the experimental async/Octree on!
https://napari.org/dev/guides/rendering.html

So one option is to turn those off, which is easier said than done when napari won't launch.
You can do `napari --reset`
But you will lose your preferences.

Anyhow for sure this is a bug in napari.
QTimer `setInterval()` expects `int` but is being passed a float.
This was being cast to int automagically, but now no longer is in python 3.10.

There are two possible fixes:
1. We cast the float to int: `self.timer.setInterval(int(POLL_INTERVAL_MS))` 
2. We make the variable an int to begin with `POLL_INTERVAL_MS = 16`

That interval seems arbitrary and isn't used anywhere else, so I lean to option 2, which is the same as the output of `int(POLL_INTERVAL_MS)`
Any thoughts @Czaki ?
I prefer assign int to POLL_INTERVAL_MS. 

Resolving patch:
diff --git a/napari/_qt/experimental/qt_poll.py b/napari/_qt/experimental/qt_poll.py
--- a/napari/_qt/experimental/qt_poll.py
+++ b/napari/_qt/experimental/qt_poll.py
@@ -11,7 +11,7 @@
 from napari.utils.events import EmitterGroup
 
 # When running a timer we use this interval.
-POLL_INTERVAL_MS = 16.666  # About 60HZ
+POLL_INTERVAL_MS = 16  # About 60HZ, needs to be an int for QTimer setInterval
 
 # If called more often than this we ignore it. Our _on_camera() method can
 # be called multiple times in on frame. It can get called because the


Test patch: