Skip to content

Instantly share code, notes, and snippets.

View DmitryTokyo's full-sized avatar
💻
Remote work

Dmitry Ovsiannikov DmitryTokyo

💻
Remote work
  • Zipsale Co. LTD.
  • Tokyo
View GitHub Profile
[
{
"coords": {
"lat": "52.65",
"lon": "90.083333333333"
},
"district": "Сибирский",
"name": "Абаза",
"population": 12272,
"subject": "Хакасия"
{
"categories_virtual_taxonomy": [
{
"id": "163870668944785",
"name": "Antiques and collectibles",
"navigational_name": "Antiques and collectibles",
"subtitle": null,
"virtual_category_ordered_children": [
{
"id": "207642374125592",
@DmitryTokyo
DmitryTokyo / server.py
Last active April 27, 2021 12:46
Server socket work
import asyncio
import socket
def set_keepalive_linux(sock, after_idle_sec=1, interval_sec=3, max_fails=5):
"""Set TCP keepalive on an open socket.
It activates after 1 second (after_idle_sec) of idleness,
then sends a keepalive ping once every 3 seconds (interval_sec),
and closes the connection after 5 failed ping (max_fails), or 15 seconds
"""