Skip to content

Commit

Permalink
Turns off loop if using real backend
Browse files Browse the repository at this point in the history
If you select a real quantum processor backend instead of the default simulator backend, the program will only send the job a single time.
  • Loading branch information
KPRoche authored Oct 3, 2019
1 parent eb96200 commit 5bc2112
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions QuantumRaspberryTie.qiskit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# or older (0.2) IBMQ object
# October 2019 -- will attempt to load SenseHat and connect to hardware.
# If that fails, then loads and launches SenseHat emulator for display instead
# October 2019 -- added extra command line parameters. Can force use of Sensehat emulator, or specify backend
# (specifying use of a non-simulator backend will disable loop)
#----------------------------------------------------------------------


Expand Down Expand Up @@ -98,6 +100,7 @@
print("Setting up...")
# This (hiding deprecation warnings) is temporary because the libraries are changing again
warnings.filterwarnings("ignore", category=DeprecationWarning)
Looping = True # this will be set false after the first go-round if a real backend is called
angle = 180
result = None
runcounter=0
Expand Down Expand Up @@ -422,15 +425,15 @@ def startIBMQ():
except:
Q=provider0.get_backend(backend)
else:
interval = 5*60
interval = 300
else: # The older IBMQ authentication technique
IBMQ.load_accounts()
try:
Q=IBMQ.get_backend(backendparm)
except:
Q=IBMQ.get_backend(backend)
else:
interval = 5*60
interval = 300
else:
exit()
#-------------------------------------------------------------------------------
Expand Down Expand Up @@ -478,7 +481,7 @@ def startIBMQ():
rainbowTie.start() # start the display thread


while True:
while Looping:
runcounter += 1

try:
Expand All @@ -498,10 +501,12 @@ def startIBMQ():
print('Backend Status: ',backend_status.status_msg)
if Q.status().status_msg == 'active':

print(' executing quantum circuit...')
print(' executing quantum circuit... on ',Q.name())
print(qcirc)
try:
qjob=execute(qcirc, Q, shots=500, memory=False)
Looping = 'simul' in Q.name()
if runcounter < 3: print("Using ", Q.name(), " ... Looping is set ", Looping)
except:
print("connection problem... half a tick and we'll try again...")
sleep(.5)
Expand Down

0 comments on commit 5bc2112

Please sign in to comment.