client.py 700 Bytes
Newer Older
Matthieu Dorier's avatar
Matthieu Dorier committed
1 2
# (C) 2018 The University of Chicago
# See COPYRIGHT in top-level directory.
Matthieu Dorier's avatar
Matthieu Dorier committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
import _pybakeclient
import pymargo

class BakeClient():

	def __init__(self, mid):
		self._client = _pybakeclient.client_init(mid._mid)

	def create_provider_handle(self, addr, mplex_id):
		ph = _pybakeclient.provider_handle_create(self._client, addr.get_hg_addr(), mplex_id)
		return BakeProviderHandle(ph)

	def shutdown_service(self, addr):
		_pybakeclient.shutdown_service(self._client, addr.get_hg_addr())
	
	def __del__(self):
		_pybakeclient.client_finalize(self._client)

class BakeProviderHandle():

	def __init__(self, ph):
		self._ph = ph
	
	def __del__(self):
		_pybakeclient.provider_handle_release(self._ph)