koalalorenzo / python-digitalocean

🐍🐳 Python module to manage Digital Ocean droplets
GNU Lesser General Public License v3.0
1.26k stars 301 forks source link

Make droplet.create() return a value - so it can be used with 'await' ? #335

Closed danryu closed 3 years ago

danryu commented 3 years ago

Currently droplet.create() wraps a synchronous POST request to the API (calls get_data()) https://github.com/koalalorenzo/python-digitalocean/blob/027b56cbf7e67dbb67673fd6462b85f2c0428f6d/digitalocean/Droplet.py#L568

Could create() be refactored to return a meaningful value? This would mean it can be used with 'await' to allow asynchronous operation, eg await droplet.create()

Otherwise you see this: TypeError: object NoneType can't be used in 'await' expression

danryu commented 3 years ago

Don't think this is necessary. FWIW I am using this in async lib gevent with Celery.