oittaa / gcp-storage-emulator

Local emulator for Google Cloud Storage
BSD 3-Clause "New" or "Revised" License
155 stars 42 forks source link

Added Context Manager to Server Class #213

Closed RudreshVeerkhare closed 3 months ago

RudreshVeerkhare commented 2 years ago

This project is really awesome tried this and solved the exact problem I was facing; I'm wondering if you'd be happy with adding context manager support to Server class. Like currently in documentation, it's given as :

from gcp_storage_emulator.server import create_server

server = create_server("localhost", 9023, in_memory=False)

server.start()
# ........
server.stop()

But after adding context manager support, it'd look like :

from gcp_storage_emulator.server import Server

with Server("localhost", 9023, in_memory=False) as server:
     # .........
     # ........

As this might look like a small change, but this would be really convenient. Also thanks for such a nice project 😁