Skip to content

Commit

Permalink
Fix error when closing client's connection
Browse files Browse the repository at this point in the history
Error: "Target thread must not be current thread"
  • Loading branch information
dtonon committed Dec 9, 2024
1 parent 0f1e350 commit ca8833d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,12 @@ def running?

def close
@running = false
@ws_client.close if @ws_client
EventMachine.stop if EventMachine.reactor_running?
@thread.join if @thread
EM.next_tick do
@ws_client.close if @ws_client
EM.add_timer(0.1) do
EM.stop if EM.reactor_running?
end
end
end

def publish(event)
Expand Down

0 comments on commit ca8833d

Please sign in to comment.