This file contains hidden or 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
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: graceful-shutdown-fast-api | |
| labels: | |
| app: graceful-shutdown-fast-api | |
| spec: | |
| replicas: 1 | |
| selector: | |
| matchLabels: |
This file contains hidden or 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
| async def connect(self, websocket: WebSocket, client_id: str) -> None: | |
| """ | |
| Connect the WebSocket | |
| Args: | |
| websocket: WebSocket | |
| id: Client ID | |
| Returns: | |
| None | |
| """ | |
| print(f"Read Flag: {read_flag()}") |
This file contains hidden or 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
| @router.post("/create-task/") | |
| async def create_task(background_tasks: BackgroundTasks) -> dict: | |
| """ | |
| Create a task and add it to the queue | |
| Args: | |
| background_tasks: BackgroundTasks | |
| Returns: | |
| dict: Response message | |
| """ | |
| if not read_flag(): |
This file contains hidden or 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
| class SignalHandler: | |
| async def handle_exit(self): | |
| """ | |
| Handle the exit of the server | |
| Args: | |
| None | |
| Returns: | |
| None |
This file contains hidden or 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
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: async-app | |
| labels: | |
| app: async-app | |
| spec: | |
| replicas: 1 | |
| selector: | |
| matchLabels: |
This file contains hidden or 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
| FROM python:3.12-slim | |
| WORKDIR /app | |
| COPY async.py . | |
| ENTRYPOINT ["python", "async.py"] |
This file contains hidden or 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 signal | |
| import random | |
| import os | |
| # Shared queue | |
| queue = asyncio.Queue() | |
| # Event to signal the producer to stop | |
| stop_event = asyncio.Event() |
This file contains hidden or 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
| [tool.poetry] | |
| name = "xxxxxxx" | |
| version = "0.1.0" | |
| description = "xxxxxxxx" | |
| authors = ["xxxxx <xxxxxx@xxxxx.com>"] | |
| readme = "README.md" | |
| [tool.poetry.dependencies] | |
| python = "^3.10" | |
| pydantic = "^1.10.8" |
This file contains hidden or 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 random | |
| def search_array(array, target): | |
| start_index = 0 | |
| end_index = len(array) - 1 | |
| is_ascending = array[start_index] < array[end_index] | |
| while start_index <= end_index: | |
| mid_index = start_index + (end_index - start_index) // 2 |
This file contains hidden or 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
| package myPackage.myAlgorithms; | |
| public class MyOrderAgnosticBinarySearch { | |
| public static void main(String[] args) { | |
| int[] nums1 = {-1, 2, 4, 6, 7, 8, 12, 15, 19, 32, 45, 67, 99}; | |
| int[] nums2 = {99, 67, 45, 32, 19, 15, 12, 8, 7, 6, 4, 2, -1}; | |
| int target = -1; | |
| System.out.println(mySearch(nums1, target)); | |
| System.out.println(mySearch(nums2, target)); | |
| } |
NewerOlder