File tree Expand file tree Collapse file tree 6 files changed +79
-7
lines changed
expected_failures/exercise_timeout Expand file tree Collapse file tree 6 files changed +79
-7
lines changed Original file line number Diff line number Diff line change 1+ # Copyright 2024 Deepgram SDK contributors. All Rights Reserved.
2+ # Use of this source code is governed by a MIT license that can be found in the LICENSE file.
3+ # SPDX-License-Identifier: MIT
4+
5+ import asyncio
6+ import time
7+ import logging , verboselogs
8+
9+ from deepgram import DeepgramClient , DeepgramClientOptions , LiveOptions
10+
11+
12+ async def main ():
13+ # for debugging
14+ config : DeepgramClientOptions = DeepgramClientOptions (
15+ verbose = logging .DEBUG , options = {"keepalive" : "true" }
16+ )
17+ deepgram : DeepgramClient = DeepgramClient ("" , config )
18+
19+ deepgram_connection = deepgram .listen .asynclive .v ("1" )
20+
21+ await deepgram_connection .start (LiveOptions ())
22+
23+ # Wait for a while to simulate a long-running connection
24+ await asyncio .sleep (600 )
25+
26+ print ("deadlock!" )
27+ try :
28+ await deepgram_connection .finish ()
29+ finally :
30+ print ("no deadlock..." )
31+
32+
33+ asyncio .run (main ())
Original file line number Diff line number Diff line change 1+ # Copyright 2024 Deepgram SDK contributors. All Rights Reserved.
2+ # Use of this source code is governed by a MIT license that can be found in the LICENSE file.
3+ # SPDX-License-Identifier: MIT
4+
5+ import time
6+ import logging , verboselogs
7+
8+ from deepgram import DeepgramClient , DeepgramClientOptions , LiveOptions
9+
10+
11+ def main ():
12+ # for debugging
13+ config : DeepgramClientOptions = DeepgramClientOptions (
14+ verbose = logging .DEBUG , options = {"keepalive" : "true" }
15+ )
16+ deepgram : DeepgramClient = DeepgramClient ("" , config )
17+ # OR
18+ # deepgram: DeepgramClient = DeepgramClient()
19+
20+ deepgram_connection = deepgram .listen .live .v ("1" )
21+
22+ deepgram_connection .start (LiveOptions ())
23+
24+ # press any key to exit
25+ input ("\n \n Press Enter to exit...\n \n " )
26+
27+ print ("deadlock!" )
28+ try :
29+ deepgram_connection .finish ()
30+ finally :
31+ print ("no deadlock..." )
32+
33+
34+ if __name__ == "__main__" :
35+ main ()
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1010
1111
1212async def main ():
13+ # for debugging
1314 config : DeepgramClientOptions = DeepgramClientOptions (verbose = logging .DEBUG )
1415 deepgram : DeepgramClient = DeepgramClient ("" , config )
16+ # OR
17+ # deepgram: DeepgramClient = DeepgramClient()
1518
1619 deepgram_connection = deepgram .listen .asynclive .v ("1" )
1720
1821 await deepgram_connection .start (LiveOptions ())
1922
20- time .sleep (
21- 30
22- ) # Deepgram will close the connection after 10-15s of silence, followed with another 5 seconds for a ping
23+ # Deepgram will close the connection after 10-15s of silence, followed with another 5 seconds for a ping
24+ await asyncio .sleep (30 )
2325
2426 print ("deadlock!" )
2527 try :
Original file line number Diff line number Diff line change 99
1010
1111def main ():
12- config : DeepgramClientOptions = DeepgramClientOptions (verbose = logging .DEBUG )
12+ # for debugging
13+ config : DeepgramClientOptions = DeepgramClientOptions (verbose = logging .SPAM )
1314 deepgram : DeepgramClient = DeepgramClient ("" , config )
15+ # OR
16+ # deepgram: DeepgramClient = DeepgramClient()
1417
1518 deepgram_connection = deepgram .listen .live .v ("1" )
1619
1720 deepgram_connection .start (LiveOptions ())
1821
19- time .sleep (
20- 30
21- ) # Deepgram will close the connection after 10-15s of silence, followed with another 5 seconds for a ping
22+ # Deepgram will close the connection after 10-15s of silence, followed with another 5 seconds for a ping
23+ time .sleep (30 )
2224
2325 print ("deadlock!" )
2426 try :
You can’t perform that action at this time.
0 commit comments