Python Forum
asyncio: WebSocketClient:connection closed (ERR): sent 1011
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
asyncio: WebSocketClient:connection closed (ERR): sent 1011
#1
Hi,

I'm using Python asyncio, everything is working fine. The only issue is, that the (*) writing data from queue into the database: df.to_sql causes the error:

"WebSocketClient:connection closed (ERR): sent 1011 (unexpected error) keepalive ping timeout; no close frame received."

  1. The WebSocket puts every minute up to 10.000 items,
  2. within max 10 seconds ( e.g. between 09:08:00 - 09:08:10 )
  3. the methode writes every items separatelly into the database (*) , because I could not find a solution for collecting data for a minute and write them once pro minute.
  4. There is enough time for writing ( e.g. between 09:08:11 - 09:08:59 ).

Question: How can I write the dataframe ( df.to_sql ...) every xx:15 (e.g. 09:08:15) ?

Thanks for your suggestions.

Regards, Michel

    async def start_processing_api_calls(self):
            while True:
                ticker = await self.api_call_queue.get()
                try:
                    data = (
                        ticker.symbol,
                        ticker.volume
                    )
                    self.current_batch.append(data)
                    df = pd.DataFrame(self.current_batch)
                    df.columns = self.COLUMN_NAMES
                    df.to_sql(self.TableName, con=self.Engine, schema=self.SchemaName, if_exists='append', index=False)        
                    self.current_batch = []               
                except Exception as e:
                    logging.error(f"Error processing API call for {ticker}: {e}")
                finally:
                    self.api_call_queue.task_done()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to umount on a closed distro ebolisa 5 1,250 Jan-03-2025, 03:50 AM
Last Post: DeaD_EyE
  A question about 'Event loop is closed' fc5igm 3 5,234 Oct-01-2024, 09:12 AM
Last Post: skdaro
  [closed] check whether an integer is 32 or 64 bits paul18fr 4 5,369 May-27-2024, 04:55 PM
Last Post: deanhystad
  Serial connection connection issue Joni_Engr 15 12,182 Aug-30-2021, 04:46 PM
Last Post: deanhystad
  ValueError: I/O operation on closed file problem aliwien 0 2,704 Apr-23-2021, 05:50 PM
Last Post: aliwien
  Run an app in a standalone terminal and wait until it's closed glestwid 2 3,429 Aug-30-2020, 08:14 AM
Last Post: glestwid
  Inclusive (closed) range with float numbers mapg 4 5,991 Apr-27-2019, 09:09 PM
Last Post: Gribouillis
  VMware View - Session opened/closed? hhh 0 2,797 May-31-2018, 10:10 AM
Last Post: hhh
  script closed before i can see the error that occurs? wrestlemy69 9 11,406 Dec-02-2016, 01:40 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020