BindToClose extended yield w/ coroutine.yield()


#1

Note that this isn’t Calling YieldFunctions from BindToClose functions hangs Studio after clicking Stop button
At least for me, just having a wait() resumes properly

My repro is this:

local t
game:BindToClose(function()
	print'closing'
	t=coroutine.running()
	print'set t;yielding'
	local s=tick()
	coroutine.yield()
	print('unyielded after '..(tick()-s))
end)

print'waiting for t'
repeat until t or not wait()
print'got t'
coroutine.resume(t)
print'resumed t'

Relevant studio output shows:

waiting for t
closing
set t;yielding
19:34:38.276 - Disconnect from 127.0.0.1|63659
got t
unyielded after 0.03760552406311
resumed t

As you can see, my thread supposedly unyields after the expected ~1/30 seconds yet if you actually run the code in studio, studio freezes for ~30 seconds (the timeout)


#2

This was intentionally changed a few months back. coroutine.yield will now yield a thread until it is explicitly resumed with coroutine.resume.

Let me tell you: this made Event:wait() way easier to code. :slight_smile:


#3

might want to reread the thread


#4

Yes, coroutine yielding doesn’t work properly in BindToClose.

It has already been reported here:


closed #5

Duplicate