labrad / pylabrad

python interface for labrad
50 stars 31 forks source link

rename async for python 3.7 compatability #358

Closed hvraven closed 5 years ago

hvraven commented 5 years ago

async has become a keyword in python 3.7 (see what's new), making the current version unusable in 3.7. This renames async to _async at the relevant locations, even though I am up for any other name. This creates a breaking change in the API as it used in the parameter list of LabradProtocol.addListener.

hvraven commented 5 years ago

One could work around the API change by adding a **kwargs parameter to addListener and check whether async is part of it. This requires only string comparison, thus the keyword introduction is not an issue.

For Python versions >= 3.7 changes to user code would still be required, but code running in older versions would work without change. I could add this if it is desired.

maffoo commented 5 years ago

I would suggest changing the parameter to sync and reversing the sense of the boolean (including the default value). We should also add a **kw args as you suggest for backwards compatibility.

hvraven commented 5 years ago

I like the idea of using sync instead and inverting the logic, gets rid of this ugly underscore. I made the changes and updated the PR. I've also added the **kwargs wrapper with a comment.