source stringlengths 3 86 | python stringlengths 75 1.04M |
|---|---|
bot.py |
import os
import sys
import threading
import discord
import pyglet
from dotenv import load_dotenv
from firework_parsing import firework_parsing
def extract_message(message_body, prefix):
if message_body.lower().startswith(prefix.lower()):
return str.strip(message_body[len(prefix):])
return None
de... |
DataLoader.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 2 20:11:53 2021
@author: gbatz97
"""
import numpy as np
import multiprocessing
import queue
from itertools import cycle
#This file implements a dataloader which does prefetching while the GPU is running.
#It intends to accelerate dataloading an... |
reduction.py | #
# Module to allow connection and socket objects to be transferred
# between processes
#
# multiprocessing/reduction.py
#
# Copyright (c) 2006-2008, R Oudkerk
# Licensed to PSF under a Contributor Agreement.
#
from __future__ import absolute_import
import os
import sys
import socket
import threading
from pickle imp... |
training.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the 'License'). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the 'license' file acc... |
watch.py | import logging
import threading
import grpc
import six
from six.moves import queue
import etcd3.etcdrpc as etcdrpc
import etcd3.events as events
import etcd3.exceptions as exceptions
import etcd3.utils as utils
_log = logging.getLogger(__name__)
class Watch(object):
def __init__(self, watch_id, iterator=Non... |
refletancia.py | #!/usr/bin/env python
import rospy
from SensorsListener import SensorsListener
#import motores
class Refletancia():
def __init__(self, sl):
self.sl = sl
def maisEsqBranco(self): return self.sl.getRefle(0) > 4
def esqBranco(self): return self.sl.getRefle(1) > 4
def dirBranco(self): return self... |
variable_scope_test.py | # Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... |
test_insert_20.py | import threading
import numpy as np
import pandas as pd
import pytest
from pymilvus import Index
from base.client_base import TestcaseBase
from utils.util_log import test_log as log
from common import common_func as cf
from common import common_type as ct
from common.common_type import CaseLabel, CheckTasks
prefix =... |
data_utils.py | # Lint as python3
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless r... |
silvia-pi.py | #!/usr/bin/python
def scheduler(dummy,state):
import time
import sys
import schedule
from datetime import datetime
sys.stdout = open("scheduler.log", "a")
sys.stderr = open("scheduler.err.log", "a")
with open("scheduler.log", "a") as fsch:
print("Starting scheduler thread ...", file=fsch)
last... |
__init__.py | # -*- coding: utf-8 -*-
"""
This file is covered by the LICENSING file in the root of this project.
"""
from werkzeug.exceptions import HTTPException
__author__ = 'Junbo Wang'
__version__ = '2.0'
from flask import Flask
from flask_restful import Api
from flask_cors import CORS
from datetime import timedelta
from ut... |
_testing.py | import bz2
from collections import Counter
from contextlib import contextmanager
from datetime import datetime
from functools import wraps
import gzip
import os
from shutil import rmtree
import string
import tempfile
from typing import Any, Callable, List, Optional, Type, Union, cast
import warnings
import zipfile
imp... |
sensordata.py | """
SleekXMPP: The Sleek XMPP Library
Implementation of xeps for Internet of Things
http://wiki.xmpp.org/web/Tech_pages/IoT_systems
Copyright (C) 2013 Sustainable Innovation, Joachim.lindborg@sust.se, bjorn.westrom@consoden.se
This file is part of SleekXMPP.
See the file LICENSE for copying per... |
clientchat.py |
import os
import sys
import threading
from socket import *
import warcode as wc
import configurationmanager as cm
import securedsocket as ss
import sys, traceback
class ClientChat:
def __init__(self,send_udp_socket,recv_udp_socket,name):
self.name = name.strip()
print("Hi " + se... |
test.py | #!/usr/bin/env python3
# Copyright 2020 Anapaya Systems
import http.server
import time
import threading
from plumbum import cmd
from acceptance.common import base
from acceptance.common import tools
from acceptance.common import scion
class Test(base.TestBase):
"""
Constructs a simple Hidden Paths topolog... |
fastscan.py | from database import mushilogger
import socket
import threading
import sys
class FastScan():
def __init__(self):
print("init NetworkScan..")
self.mlogger = mushilogger.MushiLogger()
def execute_fastscan(self, ipaddr):
#scan_range = [1, 1024]
#scan_port = [21,22,23,25,53,80,88,110,123,135,139,1... |
program.py | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... |
prepare.py | #!/usr/bin/env python2.7
# pylint: disable=bad-indentation, no-member, invalid-name, line-too-long
import os
import shutil
import random
import argparse
import multiprocessing
import cv2
import lmdb
import caffe
import numpy as np
from jfda.config import cfg
from jfda.utils import load_wider, load_celeba
from jfda.uti... |
HiwinRA605_socket_ros_test_20190626130727.py | #!/usr/bin/env python3
# license removed for brevity
#接收策略端命令 用Socket傳輸至控制端電腦
import socket
##多執行序
import threading
import time
##
import sys
import os
import numpy as np
import rospy
import matplotlib as plot
from std_msgs.msg import String
from ROS_Socket.srv import *
from ROS_Socket.msg import *
import HiwinRA605_s... |
classify_video.py | import cv2
import tensorflow as tf
import argparse
import threading
import multiprocessing
import time
import chunk_evaluator as evaluator
import slice_manager
import progressbar
def load_labels(labels_location='retrained_labels.txt'):
label = []
proto_as_ascii_lines = tf.gfile.GFile(labels_location).readline... |
db_import_multiplexer.py | # Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... |
read_from_device.py |
import serial
import time
import platform
import threading
import zephyr.message
import zephyr.protocol
import zephyr.signal
import zephyr.events
import zephyr.delayed_stream
import zephyr.testing
import zephyr.visualization
def callback(value_name, value):
if value_name == "acceleration":
print ["%010s... |
themes.py | from tkinter import *
from tkinter import ttk, messagebox
from halo import Halo
from threading import Thread
from ttkthemes import themed_tk as tk
from time import sleep
root = tk.ThemedTk()
root.geometry('800x600+500+150')
themes = root.get_themes()
def __change_theme():
while True:
for theme in themes:... |
callback.py | import json
import pycurl
from io import BytesIO
import multiprocessing
from urllib.parse import urlencode, unquote
from db_report.config import cmd_args, logger, translate as _
from bottle import route, run, request
@route('/', method='POST')
def bottle_callback():
"""
Callback handler
:return: respons... |
sandbox.py | # Copyright 2014 Google Inc. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... |
modelservicecontext.py | #Data : 2018-10-15
#Author : Fengyuan Zhang (Franklin)
#Email : franklinzhang@foxmail.com
from enum import Enum
import socket
import time
import threading
import json
import os
import sys
import zipfile
class EModelContextStatus(Enum):
EMCS_INIT_BEGIN = 1,
EMCS_INIT = 2,
EMCS_INIT_END = 3,... |
thread.py | import cv2, threading, queue
class ThreadingClass:
# initiate threading class
def __init__(self, name):
self.cap = cv2.VideoCapture(name)
# define an empty queue and thread
self.q = queue.Queue()
t = threading.Thread(target=self._reader)
t.daemon = True
t.start()
# read the frames as soon a... |
main2_lps.py | from tensorflow import keras
import numpy as np
import cv2
import os
import random
import shutil
import pandas as pd
import csv
import zipfile
from tensorflow.keras import optimizers
from tensorflow.keras.models import Sequential,Model
from tensorflow.keras.layers import Dropout, Flatten, Dense,Input
from tensorflow.ke... |
__init__.py | # This file is a part of ninfs.
#
# Copyright (c) 2017-2021 Ian Burgwin
# This file is licensed under The MIT License (MIT).
# You can find the full license text in LICENSE.md in the root of this project.
import sys
import tkinter as tk
import tkinter.ttk as ttk
import tkinter.messagebox as mb
import webbrowser
from i... |
relay_integration.py | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... |
roll_pair.py | # -*- coding: utf-8 -*-
# Copyright (c) 2019 - now, Eggroll Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2... |
_processing.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
| @purpose: Hub for running processing and analyzing raw data.
| @date: Created on Sat May 1 15:12:38 2019
| @author: Semeon Risom
| @email: semeon.risom@gmail.com
| @url: https://semeon.io/d/R33-analysis
"""
# available classes and functions
__all__ = ... |
train_pg.py | import numpy as np
import tensorflow as tf
import gym
import logz
import scipy.signal
import os
import time
import inspect
from multiprocessing import Process
#============================================================================================#
# Utilities
#====================================================... |
mapper.py | import numpy as np
import matplotlib.pyplot as plt
import os
import serial
import time
import json
import datetime
from frghardware.components.stage import Thorlabs_LTS150_xy
from frghardware.components.mono import Mono
from frghardware.components.daq import DAQ
import datetime
from tqdm import tqdm
import h5py
import ... |
mapplot.py |
from mpl_toolkits.basemap import Basemap
import BaseDomsHandler
import ResultsStorage
import numpy as np
import string
from cStringIO import StringIO
from multiprocessing import Process, Manager
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('Agg')
PARAMETER_TO_FIELD = {
"sst": "sea_water_te... |
operation_task.py | import datetime
import json
import re
import os
import requests
import time
import threading
import pickle
from django.core.mail import send_mail
from django.db import connection
from django.http import JsonResponse
from django.shortcuts import render_to_response, render
from django.core.cache import cache
from ApiMa... |
stage_op_test.py | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... |
test_fx.py | import builtins
import contextlib
import copy
import functools
import inspect
import math
import numbers
import operator
import os
import pickle
import sys
import torch
import traceback
import typing
import types
import warnings
import unittest
from math import sqrt
from torch.multiprocessing import Process
from torch.... |
braket_container.py | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompan... |
InMemoryCluster.py | # Copyright 2015 Ufora Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to i... |
progress_indicator.py | from __future__ import annotations
import re
import threading
import time
from contextlib import contextmanager
from typing import TYPE_CHECKING
from cleo._utils import format_time
from cleo.io.io import IO
if TYPE_CHECKING:
from cleo.io.outputs.output import Output
class ProgressIndicator:
"""
A pro... |
dns.py | from pymongo import MongoClient
import json
from datetime import datetime
import mysql.connector
import logging
from logging.handlers import RotatingFileHandler
from datetime import timezone
from elasticsearch import Elasticsearch
import pythonwhois
from time import sleep
from confluent_kafka import Consumer
logging.... |
LR5.py | """
Licensed under the Unlicense License;
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://unlicense.org
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BAS... |
test_smtp_mailer.py | import asyncore
from email import message_from_bytes
import smtpd
from smtplib import SMTPException
import threading
import pytest
from ..mailshake import EmailMessage, SMTPMailer
def make_emails():
return [
EmailMessage(
"Subject-%s" % num, "Content", "from@example.com", "to@example.com"
... |
user.py | #!/usr/bin/env python2.7
import argparse # new in Python2.7
import atexit
import logging
import string
import sys
import threading
import time
logging.basicConfig(level=logging.ERROR)
from yapsy.PluginManager import PluginManager
# Load the plugins from the plugin directory.
manager = PluginManager()
if __name__ =... |
test_pr_preview.py | try:
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
except ImportError:
# Python 3 case
from http.server import BaseHTTPRequestHandler, HTTPServer
import contextlib
import errno
import json
import os
import shutil
import stat
import subprocess
import tempfile
import threading
subject = os.pa... |
langserver.py | """Langserver support for autocompletions."""
# TODO: CompletionProvider
# TODO: error reporting in gui somehow
from __future__ import annotations
import dataclasses
import errno
import itertools
import logging
import os
import pathlib
import pprint
import queue
import re
import select
import shlex
import signal
impor... |
streamTest-threading.py | """
This example uses Python's built-in threading module to reach faster streaming
speeds than streamTest.py.
On a Ubuntu 9.10 machine with a AMD Athlon(tm) 64 X2 Dual Core Processor 5200+,
we got speeds up to 50kHz.
On a Mac OS 10.6 machine with a 2.53 GHz Intel Core 2 Duo Processor, we got
speeds up to 50kHz.
On ... |
rebalanceout.py | import time
from threading import Thread
import threading
from rebalance.rebalance_base import RebalanceBaseTest
from couchbase_helper.documentgenerator import BlobGenerator
from membase.api.rest_client import RestConnection
from membase.helper.rebalance_helper import RebalanceHelper
from remote.remote_util import Rem... |
pickletester.py | import collections
import copyreg
import dbm
import io
import functools
import os
import math
import pickle
import pickletools
import shutil
import struct
import sys
import threading
import unittest
import weakref
from textwrap import dedent
from http.cookies import SimpleCookie
try:
import _testbuffer
except Impo... |
fifo_queue_test.py | # Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... |
btcproxy.py | """ A groestlcoind proxy that allows instrumentation and canned responses
"""
from flask import Flask, request
from bitcoin.rpc import JSONRPCError
from bitcoin.rpc import RawProxy as BitcoinProxy
from cheroot.wsgi import Server
from cheroot.wsgi import PathInfoDispatcher
import decimal
import flask
import json
import... |
task.py | ##############################################################################
#
# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# TH... |
teos.py | #!/usr/bin/python3
import os
import subprocess
import threading
import time
import re
import pathlib
import shutil
import pprint
import json
import sys
import math
import psutil
import eosfactory.core.errors as errors
import eosfactory.core.logger as logger
import eosfactory.core.utils as utils
import eosfactory.core... |
dumping_callback_test.py | # Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... |
foreman.py | # vim:ts=4:sts=4:sw=4:expandtab
import copy
import datetime
import dateutil.parser
import glob
import json
import logging
import math
from multiprocessing import Process
import os
import random
import shutil
import subprocess
import sys
import tempfile
import traceback
from threading import Thread
import time
import u... |
client_active.py | # encoding: utf-8
"""
__auth__: 焦淑鹏
__require__: 模拟客户端,与它端进行交互
__version__: 无要求
"""
import socket
import ssl
import threading
import msgpack
import time
import sys
import datetime
from convert import Convert
from ..message_type import Message
from ..json_formatter import JsonFormatter
from ..setting import... |
tello_video.py | import socket
import threading
import time
import numpy as np
import libh264decoder
class Tello:
"""Wrapper class to interact with the Tello drone."""
def __init__(self, local_ip, local_port, imperial=False, command_timeout=.3, tello_ip='192.168.10.1',tello_port=8889):
"""
Binds to ... |
codec.py | #
# Copyright (c) 2016-2017, The OpenThread Authors.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless re... |
pfp.py | '''
Refer to https://docs.python.org/3.8/library/multiprocessing.html
'''
import multiprocessing
class MultiProcessor:
def __init__(self, context: dict=None):
self.functions = list()
self.context = context
self.results = list()
self.function_args = dict()
def register_functio... |
recordings.py | import logging
import sqlalchemy
import shortuuid
import json
import os
import time
import asyncio
import threading
import shutil
from datetime import datetime, timedelta, timezone
from rx.subject import Subject
from db import get_db, metadata
from config import LOCAL_STORAGE_PATH, REMOTE_STORAGE_PATH
from controlle... |
tcp3server.py | import socket
import threading
import CompressAndDecompress
from CompressAndDecompress import Compressed
from ToSendFromServer import ToFindData
from EncyrptAndDecrypt import Encrypt
class TCPserver():
def __init__(self):
self.server_ip='localhost'
self.server_port = 9999
def main(sel... |
test_qftpd.py | __author__ = 'mbott'
import os
import json
import unittest
from time import sleep
from qumulo.rest_client import RestClient
from qumulo.lib.request import RequestError
# Modules under test
import qftpd
# Qumulo RESTful API address/port and credentials
# Requires a running cluster and admin creds
# Update values i... |
exersize6_1.py | import toolbox
import numpy as np
np.seterr(invalid='raise')
import pylab
import multiprocessing as mp
import time
from exersize1 import initialise
def format_coord(x, y):
col = int(x+0.5)
row = int(y+0.5)
if col>=0 and col<numcols and row>=0 and row<numrows:
z = upwardNormals.T[row,col]
... |
diskover.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""diskover - Elasticsearch file system crawler
diskover is a file system crawler that index's
your file metadata into Elasticsearch.
See README.md or https://github.com/shirosaidev/diskover
for more information.
Copyright (C) Chris Park 2017-2019
diskover is released unde... |
zip.py | import os
import shutil
import threading
import zipfile
from datetime import datetime
def zip_dir(src_path, dest_path):
if dest_path.endswith('.zip'): dest_path = dest_path[:-4]
threading.Thread(target=shutil.make_archive, args=(dest_path, 'zip', src_path)).start() # Zip dir in its own thread
def unzip_dir... |
base_repository_test.py | # Copyright 2017 The Forseti Security Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ap... |
common.py | """Test the helper method for writing tests."""
from __future__ import annotations
import asyncio
import collections
from collections import OrderedDict
from contextlib import contextmanager
from datetime import timedelta
import functools as ft
from io import StringIO
import json
import logging
import os
import pathli... |
server.py | import threading
from flask import Flask
from flask_cors import CORS
from werkzeug.middleware.dispatcher import DispatcherMiddleware
from werkzeug.middleware.http_proxy import ProxyMiddleware
from werkzeug.serving import run_simple
import logging
from utils.logger import logger
from data.config import Constants
from s... |
sql_isolation_testcase.py | """
Copyright (c) 2004-Present Pivotal Software, Inc.
This program and the accompanying materials are made available under
the terms of the under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.... |
solaris_exporter.py | #!/usr/bin/python
"""
sparc-exporter
version v2021Jan05
2020 Jan 31. Initial
2020 Feb 04. Added UpTime in UpTimeCollector.
2020 Feb 09. Added DiskErrorCollector, ZpoolCollector, FmadmCollector, SVCSCollector, FCinfoCollector
2020 Dec 17. Added PrtdiagCollector, MetaStatCollector, MetaDBCollector
202... |
zsync_server.py | # -*- coding: utf-8 -*-
import zmq
import os
import time
from threading import Thread
from zhelpers import socket_set_hwm, zpipe
from multiprocessing import Queue
fileq = None
mypath = 'sync_files'
ip = 'localhost'
ports = [13330, 13331, 13332]
CHUNK_SIZE = 250000
PIPELINE = 10
def send_one(socket):
if fileq.emp... |
worker.py | from contextlib import contextmanager
import atexit
import faulthandler
import hashlib
import inspect
import io
import json
import logging
import os
import redis
import sys
import threading
import time
import traceback
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
# Ray modules
from ra... |
mbarete.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#Modulos importados
import sqlite3 #mini gestor de base de datos, muy util para pruebas y almacenar datos de nuestro programa
import time #para hacer calculos de tiempo
import datetime #para abotener y manipular datos de fechas
import os #libreria con todo los ne... |
dx_groups.py | #!/usr/bin/env python
# Adam Bowen - Aug 2017
# Description:
# This script will allow you to easily manage groups in Delphix
#
# Requirements
# pip install docopt delphixpy
# The below doc follows the POSIX compliant standards and allows us to use
# this doc to also define our arguments for the script.
"""Description
... |
bot.py | # -*- coding: utf-8 -*-
import YYK
import requests
from YYK.lib.curve.ttypes import *
from datetime import datetime
import time,datetime,random,sys,re,os,json,subprocess,codecs,threading,glob
cl = YYK.LINE()
cl.login(qr=True)
cl.loginResult()
ki = YYK.LINE()
ki.login(qr=True)
ki.loginResult()
ki2 = YYK.LINE()
ki2.l... |
44_2_multithread_GIL.py | from threading import Thread
def do_sth():
while True:
pass
Thread(target=do_sth).start()
Thread(target=do_sth).start()
do_sth()
"""
三个进程占满了八核CPU中的其中一核心。因此,多线程不可以并行,只能并发,交替处理问题.
"""
"""
我们编写的Python代码是通过Python解释器来执行的。通常使用的Python解释器是官方提供的CPython。CPython中有一个GIL(Global Interpreter Lock,全局解释器锁),其作用相当于Lock,... |
test_http.py | import gzip
import io
import json
import logging
import threading
import unittest
from spectator import Registry
from spectator.http import HttpClient
try:
from BaseHTTPServer import HTTPServer
from BaseHTTPServer import BaseHTTPRequestHandler
except ImportError:
# python3
from http.server import HTTP... |
test_io.py | """Unit tests for the io module."""
# Tests of io are scattered over the test suite:
# * test_bufio - tests file buffering
# * test_memoryio - tests BytesIO and StringIO
# * test_fileio - tests FileIO
# * test_file - tests the file interface
# * test_io - tests everything else in the io module
# * test_univnewlines - ... |
filestatemanager.py | #!/usr/bin/env python3
# -*- encoding: utf-8 -*-
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apach... |
client.py | import json
import base64
import requests
import threading
from uuid import UUID
from os import urandom
from time import timezone, sleep
from typing import BinaryIO
from binascii import hexlify
from time import time as timestamp
from locale import getdefaultlocale as locale
from .lib.util import exceptions, headers, ... |
server.py | """
Utilities for creating bokeh Server instances.
"""
import datetime as dt
import html
import inspect
import logging
import os
import pathlib
import signal
import sys
import traceback
import threading
import uuid
from collections import OrderedDict
from contextlib import contextmanager
from functools import partial,... |
docker.py | import argparse
import docker
import io
import os
import random
import requests.exceptions
import sys
import tempfile
import threading
try:
from retro import data_path
except ImportError:
def data_path():
raise RuntimeError('Could not find Gym Retro data directory')
class LogThread:
def __init__(s... |
boom.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import tkinter as tk
import random
import threading
import time
def boom():
# 第1步,实例化object,建立窗口window
window = tk.Tk()
width = window.winfo_screenwidth()
height = window.winfo_screenheight()
a = random.randrange(0, width)
b = random.randrange(0, he... |
web_datasets.py | from __future__ import absolute_import, print_function, division
import logging
import numpy as np
import os
import re
import time
from base64 import b64encode
from matplotlib.figure import Figure
from matplotlib.ticker import NullLocator
from matplotlib.backends.backend_agg import FigureCanvasAgg
from threading import... |
classify_tpu_standlone.py |
# Copyright (c) HP-NTU Digital Manufacturing Corporate Lab, Nanyang Technological University, Singapore.
#
# This source code is licensed under the Apache-2.0 license found in the
# LICENSE file in the root directory of this source tree.
import argparse
from edgetpu.classification.engine import ClassificationE... |
monitors.py | from __future__ import absolute_import
import logging
import threading
from .sleeper import Sleeper
log = logging.getLogger(__name__)
DEFAULT_MONITOR_THREAD_JOIN_TIMEOUT = 5
class Monitors(object):
def _init_monitor_thread(self, name, target_name=None, target=None, start=False, config=None):
self.mon... |
multiprocessing_class.py | from multiprocessing import Process
import os
def info(title):
print(title)
print('module name:', __name__)
print('parent process:', os.getppid())
print('process id:', os.getpid())
def f(name):
info('function f')
print('hello', name)
if __name__ == '__main__':
p = Process(target=f, args=... |
test_weakref.py | import gc
import sys
import unittest
import collections
import weakref
import operator
import contextlib
import copy
import threading
import time
import random
from test import support
from test.support import script_helper
# Used in ReferencesTestCase.test_ref_created_during_del() .
ref_from_del = No... |
serial_comms.py | #!/usr/bin/env python
""" Low-level serial communications handling """
import sys, threading, logging
import re
import serial # pyserial: http://pyserial.sourceforge.net
from .exceptions import TimeoutException
from . import compat # For Python 2.6 compatibility
class SerialComms(object):
""" Wraps all low-lev... |
ontology_annotatorServer.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime
import json
import os
import random as _random
import sys
import traceback
from getopt import getopt, GetoptError
from multiprocessing import Process
from os import environ
from wsgiref.simple_server import make_server
import requests as _requests
from json... |
cache_race_repro.py | import time
import hashlib
import argparse
import os
import sys
import random
import logging
from cachetools import cached, TTLCache
from threading import Lock, Thread
NUM_THREADS = 4
if os.getenv("NUM_THREADS"):
NUM_THREADS = int(os.getenv("NUM_THREADS"))
NUM_RUNS = 100
if os.getenv("NUM_RUNS"):
NUM_THREADS... |
util.py | # -*- coding: utf-8 eval: (yapf-mode 1) -*-
#
# January 21 2019, Christian E. Hopps <chopps@labn.net>
#
# Copyright (c) 2019, LabN Consulting, L.L.C.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may ob... |
lambda_executors.py | import os
import re
import json
import time
import logging
import threading
import subprocess
# from datetime import datetime
from multiprocessing import Process, Queue
try:
from shlex import quote as cmd_quote
except ImportError:
# for Python 2.7
from pipes import quote as cmd_quote
from localstack import ... |
test_search_by_id.py | import pdb
import copy
import struct
import pytest
import threading
import datetime
import logging
from time import sleep
from multiprocessing import Process
import numpy
from milvus import IndexType, MetricType
from utils import *
dim = 128
table_id = "test_search"
add_interval_time = 2
vectors = gen_vectors(6000, d... |
pivideostream.py | # import the necessary packages
from picamera.array import PiRGBArray
from picamera import PiCamera
from threading import Thread
import cv2
class PiVideoStream:
def __init__(self, resolution=(640,480), framerate=32):
# initialize the camera and stream
self.camera = PiCamera()
self.camera.resolution = resolution... |
ROXXANE1_0.py | import datetime
import json
import math
import random
import threading
import tkinter as tk
import webbrowser
from datetime import *
from time import sleep
from tkinter import *
import pandas as pd
import psutil
import pyaudio
import pyautogui
import pyperclip
import pyttsx3
import qrcode
import requests
import speech_... |
demo6.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Topic: 线程锁
多线程和多进程最大的不同在于,多进程中,同一个变量,各自有一份拷贝存在于每个进程中,互不影响,
而多线程中,所有变量都由所有线程共享,所以,任何一个变量都可以被任何一个线程修改,
因此,线程之间共享数据最大的危险在于多个线程同时改一个变量,把内容给改乱了。
"""
import time, threading
# 假定这是你的银行存款:
balance = 0
lock = threading.Lock()
def change_it(n):
# 先存后取,结果应该为0:
global b... |
newevent.py | #---------------------------------------------------------------------------
# Name: newevent.py
# Purpose: Easy generation of new events classes and binder objects.
#
# Author: Miki Tebeka <miki.tebeka@gmail.com>
#
# Created: 18-Sept-2006
# Copyright: (c) 2006-2020 by Total Control Software
# Lic... |
launch_test.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import multiprocessing as mp
import os
import shutil
import subprocess
import tempfile
imp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.