async def get_lease_async(self, partition_id): """ Return the lease info for the specified partition. Can return null if no lease has been created in the store for the specified partition. :returns: lease info for the partition, or `None`. """ try: blob = await self.host.loop.run_in_executor( self.executor, functools.partial(self.storage_client.get_blob_to_text, self.lease_container_name, partition_id)) lease = AzureBlobLease() lease.with_blob(blob) async def state(): """ Allow lease to curry storage_client to get state """ try: loop = asyncio.get_event_loop() res = await loop.run_in_executor( self.executor, functools.partial( self.storage_client.get_blob_properties, self.lease_container_name, partition_id)) return res.properties.lease.state except Exception as err: # pylint: disable=broad-except _logger.error("Failed to get lease state {} {}".format( err, partition_id)) lease.state = state return lease except Exception as err: # pylint: disable=broad-except _logger.error("Failed to get lease {} {}".format( err, partition_id))
async def get_lease_async(self, partition_id): """ Return the lease info for the specified partition. Can return null if no lease has been created in the store for the specified partition. :param partition_id: The partition ID. :type partition_id: str :return: lease info for the partition, or `None`. :rtype: ~azure.eventprocessorhost.lease.Lease """ try: blob = await self.host.loop.run_in_executor( self.executor, functools.partial( self.storage_client.get_blob_to_text, #self.lease_container_name, partition_id)) self.lease_container_name + '/' + self.consumer_group_directory, partition_id)) lease = AzureBlobLease() lease.with_blob(blob) async def state(): """ Allow lease to curry storage_client to get state """ try: loop = asyncio.get_event_loop() res = await loop.run_in_executor( self.executor, functools.partial( self.storage_client.get_blob_properties, #self.lease_container_name, self.lease_container_name + '/' + self.consumer_group_directory, partition_id)) return res.properties.lease.state except Exception as err: # pylint: disable=broad-except _logger.error("Failed to get lease state %r %r", err, partition_id) lease.state = state return lease except Exception as err: # pylint: disable=broad-except _logger.error("Failed to get lease %r %r", err, partition_id)
async def get_lease_async(self, partition_id): """ Return the lease info for the specified partition. Can return null if no lease has been created in the store for the specified partition. :param partition_id: The partition ID. :type partition_id: str :return: lease info for the partition, or `None`. :rtype: ~azure.eventprocessorhost.lease.Lease """ try: blob = await self.host.loop.run_in_executor( self.executor, functools.partial( self.storage_client.get_blob_to_text, self.lease_container_name, partition_id)) lease = AzureBlobLease() lease.with_blob(blob) async def state(): """ Allow lease to curry storage_client to get state """ try: loop = asyncio.get_event_loop() res = await loop.run_in_executor( self.executor, functools.partial( self.storage_client.get_blob_properties, self.lease_container_name, partition_id)) return res.properties.lease.state except Exception as err: # pylint: disable=broad-except _logger.error("Failed to get lease state %r %r", err, partition_id) lease.state = state return lease except Exception as err: # pylint: disable=broad-except _logger.error("Failed to get lease %r %r", err, partition_id)