Blog post: https://segmentfault.com/a/1190000017136059
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def __init__(self, fileno, mode=None, close=True): | |
- if not isinstance(fileno, (int, long)): | |
+ if not isinstance(fileno, integer_types): | |
raise TypeError('fileno must be int: %r' % fileno) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::comm::{Select, Receiver}; | |
use std::collections::HashMap; | |
trait Endpoint { | |
fn register(&self, selector: &Select) -> uint; | |
fn on_event(&self); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ssl | |
from OpenSSL import SSL | |
ctx = SSL.Context(SSL.TLSv1_2_METHOD) | |
ctx.set_options(SSL.VERIFY_NONE) | |
ctx.use_privatekey_file('tests/certs/ssl_key.pem') | |
ctx.use_certificate_chain_file('tests/certs/ssl_cert.pem') | |
server = SSL.Connection(ctx, None) | |
server.set_accept_state() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import ssl | |
import threading | |
import socket | |
import gc | |
import uvloop | |
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/uvloop/sslproto.pxd b/uvloop/sslproto.pxd | |
index 30efa5c..e3f79a2 100644 | |
--- a/uvloop/sslproto.pxd | |
+++ b/uvloop/sslproto.pxd | |
@@ -27,6 +27,7 @@ cdef class SSLProtocol: | |
object _waiter | |
object _loop | |
_SSLProtocolTransport _app_transport | |
+ bint _app_transport_created | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"openapi": "3.0.2", "info": {"title": "DCFS Metadata Service", "version": "1.2.0a0"}, "paths": {"/version": {"get": {"summary": "Get Version", "operationId": "get_version_version_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}}}, "/metadata_index": {"get": {"tags": ["Index"], "summary": "List Metadata Indexes", "description": "List all the metadata key paths indexed in the database.", "operationId": "list_metadata_indexes_metadata_index_get", "responses": {"200": {"description": "Successful Response", "content": {"application/json": {"schema": {}}}}}, "security": [{"HTTPBasic": []}]}}, "/metadata_index/{path}": {"post": {"tags": ["Index"], "summary": "Create Metadata Indexes", "description": "Create a database index on the given metadata key path.", "operationId": "create_metadata_indexes_metadata_index__path__post", "parameters": [{"required": true, "schema": {"title": "Path"}, "name": "path", "in": "path"}], "responses": {"201": {"descript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"openapi":"3.0.2","info":{"title":"DCFS Metadata Service","version":"1.2.0a0"},"paths":{"/version":{"get":{"summary":"Get Version","operationId":"get_version_version_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/_status":{"get":{"summary":"Get Status","operationId":"get_status__status_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/metadata_index":{"get":{"tags":["Index"],"summary":"List Metadata Indexes","description":"List all the metadata key paths indexed in the database.","operationId":"list_metadata_indexes_metadata_index_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"HTTPBasic":[]}]}},"/metadata_index/{path}":{"post":{"tags":["Index"],"summary":"Create Metadata Indexes","description":"Create a database index on the given metadata key path.","operationId":"create_metadata_indexes_metadata_index__path_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This code demonstrates how FastAPI server freezes with SQLAlchemy under concurrency, | |
if you're mixing blocking operations with async calls inproperly. | |
(pip install sqlalchemy httpx fastapi uvicorn) | |
You will see 15 (not 20!) "Handling xxx", then the server freezes for minutes, | |
refusing to serve any request. | |
This is caused by "resource starvation" - the default SQLAlchemy connection pool size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.1.1/normalize.min.css" rel="stylesheet" | |
type="text/css"/> | |
<script charset="utf-8" src="https://d3js.org/d3.v3.js"></script> | |
<style> | |
html { |
OlderNewer