Even though React provides Error Boundaries API, it is not a good candidate, nor is relevant for handling GraphQL query errors.
import { useState, useCallback } from 'react';
[ | |
{ | |
"name": "your_app", | |
"image": "${image_repo_arn}:${image_tag}", | |
"essential": true, | |
"memoryReservation": 300, | |
"portMappings": [ | |
{ | |
"hostPort": 80, | |
"containerPort": 8000, |
import logging | |
from scrapy import signals | |
from scrapy.crawler import Crawler | |
from twisted.internet import reactor | |
from xxx.scraper.spiders import XXXSpider | |
logger = logging.getLogger(__name__) |
Even though React provides Error Boundaries API, it is not a good candidate, nor is relevant for handling GraphQL query errors.
import { useState, useCallback } from 'react';
from collections import Mapping | |
from dataclasses import dataclass | |
from typing import Any, Tuple | |
@dataclass() | |
class SignalHandlerContext: | |
sender: Any | |
args: Tuple[Any] | |
kwargs: Mapping |
""" | |
with Python 3.8, you can use context manager with cProfile.Profile() | |
""" | |
def profile(func, filename="stats"): | |
def wrapper(*args, **kwargs): | |
import cProfile, pstats, io | |
from pstats import SortKey | |
pr = cProfile.Profile() | |
pr.enable() |
async *genLogs() { | |
while (true) { | |
yield await window.pywebview.api.gen_logs(); | |
} | |
} | |
const g = genLogs(); | |
(await g.next()).value // 1 | |
(await g.next()).value // 2 |
""" | |
Implementation 1: Infinite Loop in Consumers | |
The problem: | |
the serving line is busy waiting | |
""" | |
import queue | |
import threading |
from typing import Dict | |
# Helper function to generate dict object | |
def get_menu() -> Dict[str, dict]: | |
return { | |
"TIMMY_BLACK": { | |
"item": "Timmy's Coffee Barista's Black", | |
"sugar_free": True, | |
"with_milk": False, | |
}, |
class FilterableDict(dict): | |
def __init__(self, *args, **kwargs): | |
dict.__init__(self, *args, **kwargs) | |
def filter(self, predicate): | |
key_copy = tuple(self.keys()) # use Tuple to further reduce memory footprint | |
for k in key_copy: | |
if predicate(k, self.get(k)): | |
del self[k] | |
return self |