Skip to content

Commit

Permalink
Revert "Use of Pythonic with statements"
Browse files Browse the repository at this point in the history
This reverts commit 81adc4c.
  • Loading branch information
JonathanCrd committed Jul 23, 2019
1 parent a3df531 commit 27b2a2d
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions samples/smoketest/EventHubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,24 @@ def GetPartitionIds(self):
return partition_ids

def SendAndReceiveEvents(self, partitionID):
with self.client.create_consumer(consumer_group="$default", partition_id=partitionID, event_position=EventPosition(datetime.utcnow())) as consumer:
consumer = self.client.create_consumer(consumer_group="$default", partition_id=partitionID, event_position=EventPosition(datetime.utcnow()))

print("Sending events...")
with self.client.create_producer(partition_id=partitionID) as producer:
event_list = [
EventData(b"Test Event 1 in Python"),
EventData(b"Test Event 2 in Python"),EventData(b"Test Event 3 in Python")]
producer.send(event_list)
print("\tdone")

print("Receiving events...")
received = consumer.receive(max_batch_size=len(event_list), timeout=2)
for event_data in received:
print("\tEvent Received: " + event_data.body_as_str())

print("\tdone")
print("Sending events...")
producer = self.client.create_producer(partition_id=partitionID)
event_list = [EventData(b"Test Event 1 in Python"),EventData(b"Test Event 2 in Python"),EventData(b"Test Event 3 in Python")]
producer.send(event_list)
producer.close()
print("\tdone")

print("Receiving events...")
received = consumer.receive(max_batch_size=len(event_list), timeout=2)
for event_data in received:
print("\tEvent Received: " + event_data.body_as_str())
consumer.close()
print("\tdone")

if(len(received) != len(event_list)):
raise Exception("Error, expecting {0} events, but {1} were received.".format(str(len(event_list)),str(len(received))))
if(len(received) != len(event_list)):
raise Exception("Error, expecting {0} events, but {1} were received.".format(str(len(event_list)),str(len(received))))

def Run(self):
print()
Expand Down

0 comments on commit 27b2a2d

Please sign in to comment.