<commit_before># -*- coding: utf-8 -*-

import json
# from asyncio import sleep, ensure_future, wait_for, gather, TimeoutError
from ccxt.async_support import Exchange
from ccxt import NotSupported
from websockets.client import connect
from ccxtpro.base.client import Client

# from websockets.exceptions import ConnectionClosed
# import websockets.exceptions


class WebsocketsClient(Client):

    def closed(self):
        return self.connection.closed

    def receive(self):
        return self.connection.receive()

    def handle_message(self, message):
        raise NotSupported('handle_message() not implemented in websockets-version yet')

    def create_connection(self, session):
        return connect(self.url, ping_interval=self.keepAlive, ping_timeout=self.keepAlive)

    def send(self, message):
        print(Exchange.iso8601(Exchange.milliseconds()), 'sending', message)
        return self.connection.send(json.dumps(message, separators=(',', ':')))

    def close(self, code):
        return self.connection.close(code)


# -----------------------------------------------------------------------------


# class WebSocketClientWs(object):

#     url = None
#     ws = None
#     futures = {}
#     on_message_callback = None
#     on_error_callback = None
#     on_close_callback = None
#     keepAlive = 3000
#     connectionTimeout = 10000  # 10 seconds by default, false to disable

#     def __init__(self, url, on_message_callback, on_error_callback, on_close_callback, config={}):
#         defaults = {
#             'url': url,
#             'on_message_callback': on_message_callback,
#             'on_error_callback': on_error_callback,
#             'on_close_callback': on_close_callback,<commit_msg>websockets_client.py async def close<commit_after># -*- coding: utf-8 -*-

import json
# from asyncio import sleep, ensure_future, wait_for, gather, TimeoutError
from ccxt.async_support import Exchange
from ccxt import NotSupported
from websockets.client import connect
from ccxtpro.base.client import Client

# from websockets.exceptions import ConnectionClosed
# import websockets.exceptions


class WebsocketsClient(Client):

    def closed(self):
        return self.connection.closed

    def receive(self):
        return self.connection.receive()

    def handle_message(self, message):
        raise NotSupported('handle_message() not implemented in websockets-version yet')

    def create_connection(self, session):
        return connect(self.url, ping_interval=self.keepAlive, ping_timeout=self.keepAlive)

    def send(self, message):
        print(Exchange.iso8601(Exchange.milliseconds()), 'sending', message)
        return self.connection.send(json.dumps(message, separators=(',', ':')))

    async def close(self, code):
        return await self.connection.close(code)


# -----------------------------------------------------------------------------


# class WebSocketClientWs(object):

#     url = None
#     ws = None
#     futures = {}
#     on_message_callback = None
#     on_error_callback = None
#     on_close_callback = None
#     keepAlive = 3000
#     connectionTimeout = 10000  # 10 seconds by default, false to disable

#     def __init__(self, url, on_message_callback, on_error_callback, on_close_callback, config={}):
#         defaults = {
#             'url': url,
#             'on_message_callback': on_message_callback,
#             'on_error_callback': on_error_callback,
#             'on_close_callback': on_close_callback,
{'fraction_non_alphanumeric': 0.1390236939765915, 'fraction_numerical': 0.009135027119611762, 'mean_word_length': 2.9326599326599325, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4250771', 'n_tokens_mistral': 1008, 'n_tokens_neox': 948, 'n_words': 236}