Repository: Flexget/Flexget

Issue:
Flexget is incompatible with python 3.7
<!---
Before opening an issue, verify:

- Is this a feature request? Post it on https://feathub.com/Flexget/Flexget
- Did you recently upgrade? Look at the Change Log and Upgrade Actions to make sure that you don't need to make any changes to your config https://flexget.com/ChangeLog https://flexget.com/UpgradeActions
- Are you running FlexGet as a daemon? Stop it completely and then start it again https://flexget.com/CLI/daemon
- Did you search to see if the issue already exists? https://github.com/Flexget/Flexget/issues
- Did you fill out the issue template as completely as possible?

The issue template is here because it helps to ensure you submitted all the necessary information the first time, and allows us to more quickly review issues. Please fill it out correctly and do not ignore it, no matter how irrelevant you think it may be. Thanks in advance for your help with this!
--->
### Expected behaviour:
<!---
Please don't just say "it doesn't crash" or "it works". Explain what the expected result is.
--->
I run `flexget --cron execute`, and it does its job and exits silently. It however fails to start because of a dependency error.


### Actual behaviour:

The program crashes during the import phase, since a dependency, `rpyc`, uses a newly reserved word in Python 3.7.

The actual fix is simple: bump the `rpyc` requirement to at least 4.0.0. In my own set-up, this appeared to fix it, but it did complain about package versions. It might be that some plugins do suffer, my config isn't that special.

### Steps to reproduce:
- Step 1: Run flexget with Python 3.7
- Stop 2: Observe crash

#### Config:
Config isn't relevant to this issue, running Python 3.7 is. Either way:
```
tasks:
    Arch Linux ISOs:
        rss: https://www.archlinux.org/feeds/releases/
        accept_all: yes
        transmission: SECRET CONFIG

schedules:
        - tasks: '*'
          interval:
                  hours: 1
```
  
#### Log:
```
Traceback (most recent call last):
  File "/var/lib/flexget/.local/bin/flexget", line 7, in <module>
    from flexget import main
  File "/var/lib/flexget/.local/lib/python3.7/site-packages/flexget/__init__.py", line 12, in <module>                                                                                          
    from flexget.manager import Manager
  File "/var/lib/flexget/.local/lib/python3.7/site-packages/flexget/manager.py", line 38, in <module>                                                                                           
    from flexget.ipc import IPCClient, IPCServer  # noqa
  File "/var/lib/flexget/.local/lib/python3.7/site-packages/flexget/ipc.py", line 10, in <module>                                                                                               
    import rpyc
  File "/var/lib/flexget/.local/lib/python3.7/site-packages/rpyc/__init__.py", line 50
    from rpyc.utils.helpers import async, timed, buffiter, BgServingThread, restricted
                                       ^
SyntaxError: invalid syntax
```

### Additional information:

- FlexGet version: 2.14.15
- Python version: 3.7.0
- Installation method: `pip install --user`
- Using daemon (yes/no): no
- OS and version: Arch Linux ARM

<!---
In config and debug/crash logs, remember to redact any personal or sensitive information such as passwords, API keys, private URLs and so on.

Please verify that the following data is present before submitting your issue:

- Link to a paste service or paste above the relevant config (preferably full config, including templates if present). Please make sure the paste does not expire, if possible.
- Link to a paste service or paste above debug-level logs of the relevant task/s (use `flexget -L debug execute --tasks <Task_name>`).
- FlexGet version (use `flexget -V` to get it).
- Full Python version, for example `2.7.11` (use `python -V` to get it). Note that FlexGet is not supported for use with Python v3.0, 3.1, 3.2 or 3.6.
- Installation method (pip, git install, etc).
- Whether or not you're running FlexGet as a daemon.
- OS and version.
- Attach crash log if one was generated, in addition to the debug-level log. It can be found in the directory with your config file.
--->



Discussion:
This corresponds to tomerfiliba/rpyc#253
Another issue with 3.7 is `PyYAML==3.12` not building. According to https://github.com/yaml/pyyaml/issues/126 where the bug was reported, v3.13 fixes this issue.
We need to add 3.7 tests to circleci

Resolving patch:
diff --git a/flexget/ipc.py b/flexget/ipc.py
--- a/flexget/ipc.py
+++ b/flexget/ipc.py
@@ -61,6 +61,10 @@ class DaemonService(rpyc.Service):
     # This will be populated when the server is started
     manager = None
 
+    def on_connect(self, conn):
+        self._conn = conn
+        super(DaemonService, self).on_connect(conn)
+
     def exposed_version(self):
         return IPC_VERSION
 
@@ -98,12 +102,14 @@ def client_out_stream(self):
 
 
 class ClientService(rpyc.Service):
-    def on_connect(self):
+    def on_connect(self, conn):
+        self._conn = conn
         """Make sure the client version matches our own."""
         daemon_version = self._conn.root.version()
         if IPC_VERSION != daemon_version:
             self._conn.close()
             raise ValueError('Daemon is different version than client.')
+        super(ClientService, self).on_connect(conn)
 
     def exposed_version(self):
         return IPC_VERSION


Test patch: