Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

python freezing/not responding in 300 trial loop

Hi, we're trying to run a loop of 300 trials of a shape stimulus with an optional key response. After some amount of trials (not always the same), python is going non-responsive and the task is freezing in place. In some cases, we can esc and quit, in some cases the whole computer is frozen.

The images are presented by creating two lists, on with the shape name, one with an inter-stimulus interval time, both of which are randomized. In the loop:

#Prepare tab: 

from openexp.canvas import canvas

shape = shapes.pop() #from the randomized list
ISI = timings.pop()

self.experiment.set("trial_shape", shape)
self.experiment.set("trial_ISI", ISI)
canvas_shape = canvas(exp)
canvas_blank = canvas(exp)

#Run tab:
#my_keyboard = Keyboard(keylist=[1], timeout=0)
#my_keyboard.flush()
duration_shape = 100
duration_blank = self.experiment.get('trial_ISI')

if shape == 'yellow_square':
	canvas_shape.rect(-43, -43, 86, 86, fill=True, color='yellow')
elif shape == "blue_square":
	canvas_shape.rect(-43, -43, 86, 86, fill=True, color='blue')
elif shape == "green_square":
	canvas_shape.rect(-43, -43, 86, 86, fill=True, color='green')
elif shape == "red_square":
	canvas_shape.rect(-43, -43, 86, 86, fill=True, color='red')
elif shape == 'yellow_circle':
	canvas_shape.circle(0, 0, 43, fill=True, color='yellow')
elif shape == 'blue_circle':
	canvas_shape.circle(0, 0, 43, fill=True, color='blue')
elif shape == 'green_circle':
	canvas_shape.circle(0, 0, 43, fill=True, color='green')
elif shape == 'red_circle':
	canvas_shape.circle(0, 0, 43, fill=True, color='red')
elif shape == 'yellow_triangle':
	canvas_shape.polygon([(0,-43), (50,43), (-50,43)], fill=True, color='yellow')
elif shape == 'blue_triangle':
	canvas_shape.polygon([(0,-43), (50,43), (-50,43)], fill=True, color='blue')
elif shape == 'green_triangle':
	canvas_shape.polygon([(0,-43), (50,43), (-50,43)], fill=True, color='green')
elif shape == 'red_triangle':
	canvas_shape.polygon([(0,-43), (50,43), (-50,43)], fill=True, color='red')
elif shape in ['yellow_star', 'blue_star', 'green_star', 'red_star']:
	n1 = -5, -70
	n2 = 5, -20
	n3 = 55, 0
	n4 = 15, 20
	n5 = 25, 70
	n6 = -5, 40
	n7 = -35, 70
	n8 = -25, 20
	n9 = -65, 0
	n10 = -15, -20
	
	if shape == 'yellow_star':
			starColor = 'yellow'
	elif shape == 'blue_star':
			starColor = 'blue'
	elif shape == 'green_star':
			starColor = 'green'
	elif shape == 'red_star':
			starColor = 'red'
	canvas_shape.polygon([n1, n2, n3, n4, n5, n6, n7, n8, n9, n10], fill=True, color=starColor)
	# Element interface
	canvas_shape['star'] = Polygon([n1, n2, n3, n4, n5, n6, n7, n8, n9, n10], fill=True, color=starColor)

show_time_shape = canvas_shape.show()
exp.set('onset_time_shape', show_time_shape)		
while self.time() - show_time_shape < duration_shape:
#	if not key:
#		key, time = my_keyboard.get_key()
	print()
# Show the second canvas, and poll the keyboard for the
# specified duration.       
show_time_blank = canvas_blank.show()
while self.time() - show_time_blank < duration_blank:
#	if not key: 
#		key, time = my_keyboard.get_key()
	print()
exp.set('response', key)
if key:
	exp.set('response_time', int(round(time-show_time_shape)))
else:
	exp.set('response_time', 0)

I've commented out the key response functionality in trying to diagnose what is causing the issue. Also have tried this using

path = exp.get_file("stimuli/%s.png"%exp.get("trial_shape"))

canvas_shape.image(path)

instead of shape functions, still having the same issue. There's no error being thrown, have tried enabling garbage collection and disabling.

Comments

  • a note: changing the while loops to clock.sleep(duration) for each canvas solves the issue, so the while loop seems to be the problem, however it doesn't allow for accurate recording of response time by continuous checking of get_key(), and I've seen that countdown time logic for the while loop suggested in other conversations.

  • Note two for future devs: code for timing example is here. I found adding get_key(timeout=0) helped with the freezing problem.

  • Note two: problem is CPU usage during the while loops.

  • Hi @kazald,

    I replied in your other discussion on this issue. Please don't double post your question, as this makes it harder to keep the overview.

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games