python_asyncio_course/6_tasks/6_09_07_rings.py

355 lines
11 KiB
Python

import asyncio
from typing import Dict
data = [
{
"Name": "Company1",
"Address": "9974 Lloyd Radial Suite 005, Andrewfort, PW 45078",
"Phone": "829-338-4124x62279",
"Email": "yhiggins@bishop-gentry.com",
"Website": "https://www.griffith-diaz.org/",
"Year": 1981,
"Employees": 2935,
"Description": "Advanced eco-centric secured line",
"CEO": "Amanda Hall",
"TaxID": 8627654889,
"call_time": 8,
},
{
"Name": "Company2",
"Address": "7703 Craig Spurs Suite 391, Acostafurt, MT 24156",
"Phone": "225-321-1903",
"Email": "amandathomas@jones.biz",
"Website": "http://www.adkins.org/",
"Year": 2008,
"Employees": 2593,
"Description": "Sharable next generation hardware",
"CEO": "Jacob Dunlap",
"TaxID": 2307021392,
"call_time": 2,
},
{
"Name": "Company3",
"Address": "5850 Stewart Club Suite 286, Carolynfurt, AR 69364",
"Phone": "792.763.2559x8121",
"Email": "berrymichael@glass-santos.com",
"Website": "https://www.white.biz/",
"Year": 2006,
"Employees": 21,
"Description": "User-friendly bi-directional software",
"CEO": "Carl Bautista",
"TaxID": 2470607513,
"call_time": 1,
},
{
"Name": "Company4",
"Address": "4381 Roberts Parks, Payneside, AZ 03840",
"Phone": "(467)414-0033x4541",
"Email": "ugonzalez@shelton.com",
"Website": "https://www.adams.com/",
"Year": 2011,
"Employees": 7084,
"Description": "Cloned dedicated website",
"CEO": "David Huffman",
"TaxID": 7462166908,
"call_time": 5,
},
{
"Name": "Company5",
"Address": "141 Shannon Plaza, Janetshire, FM 18139",
"Phone": "(301)716-0789x919",
"Email": "adamsanchez@jones-johnson.com",
"Website": "http://www.perez.net/",
"Year": 2011,
"Employees": 8458,
"Description": "Extended directional initiative",
"CEO": "Monique Anderson",
"TaxID": 1315678326,
"call_time": 9,
},
{
"Name": "Company6",
"Address": "8232 Nicole Isle, New Sandra, DE 67218",
"Phone": "+1-990-955-0294x551",
"Email": "pmason@lynch.net",
"Website": "http://www.ferrell.com/",
"Year": 2016,
"Employees": 5698,
"Description": "Automated human-resource methodology",
"CEO": "Jessica Love",
"TaxID": 4830095509,
"call_time": 7,
},
{
"Name": "Company7",
"Address": "886 Barrett Street Suite 817, Laurenstad, NH 86979",
"Phone": "+1-208-883-7438x43251",
"Email": "rjenkins@flores.info",
"Website": "http://www.morse-willis.com/",
"Year": 2022,
"Employees": 4772,
"Description": "Persevering motivating info-mediaries",
"CEO": "Brittany Freeman",
"TaxID": 6278265190,
"call_time": 1,
},
{
"Name": "Company8",
"Address": "USCGC Hanna, FPO AE 22431",
"Phone": "817-374-2328",
"Email": "tgarcia@greer.com",
"Website": "https://mason.com/",
"Year": 1985,
"Employees": 7270,
"Description": "Integrated 4thgeneration frame",
"CEO": "Michelle Cardenas",
"TaxID": 2584423305,
"call_time": 11,
},
{
"Name": "Company9",
"Address": "60164 Bailey Mountains, West Kaitlinside, AZ 10362",
"Phone": "001-261-799-2627x62104",
"Email": "kathryn73@burgess-berry.com",
"Website": "https://ramirez.info/",
"Year": 1984,
"Employees": 2211,
"Description": "Cross-group web-enabled open system",
"CEO": "Benjamin Sawyer",
"TaxID": 9449376713,
"call_time": 4,
},
{
"Name": "Company10",
"Address": "178 Lewis River, New Alexander, MS 54707",
"Phone": "568.275.2394x9402",
"Email": "walterrobert@johnson-jacobs.biz",
"Website": "http://www.olson-weber.info/",
"Year": 1981,
"Employees": 8674,
"Description": "Up-sized incremental database",
"CEO": "Alexandra Johnson",
"TaxID": 2351268827,
"call_time": 6,
},
{
"Name": "Company11",
"Address": "4709 Brooks Camp Suite 799, Port Natalie, NY 99637",
"Phone": "(818)703-8797",
"Email": "pamelajohnson@matthews-nelson.com",
"Website": "https://watkins.biz/",
"Year": 1998,
"Employees": 9951,
"Description": "Re-contextualized logistical extranet",
"CEO": "Kelly Savage",
"TaxID": 2234091865,
"call_time": 1,
},
{
"Name": "Company12",
"Address": "0372 Jared Isle Suite 075, South Anthony, GU 21805",
"Phone": "451.393.2570x70097",
"Email": "kendramurray@olson.biz",
"Website": "https://clark.net/",
"Year": 2010,
"Employees": 7653,
"Description": "Open-architected exuding functionalities",
"CEO": "Anita Peterson",
"TaxID": 5838627215,
"call_time": 4,
},
{
"Name": "Company13",
"Address": "5680 Horton Trail Suite 057, Johnsontown, WI 83282",
"Phone": "001-735-722-1031x070",
"Email": "amywalker@smith.org",
"Website": "https://www.daniel-butler.info/",
"Year": 2000,
"Employees": 2400,
"Description": "Universal bi-directional leverage",
"CEO": "Christina Wright MD",
"TaxID": 7573435589,
"call_time": 8,
},
{
"Name": "Company14",
"Address": "05330 Calhoun Locks, East Elizabeth, OR 21993",
"Phone": "201.750.6003",
"Email": "andersonbrian@hamilton.com",
"Website": "https://www.ochoa-freeman.com/",
"Year": 2000,
"Employees": 5806,
"Description": "Open-source 5thgeneration open system",
"CEO": "Garrett Griffin",
"TaxID": 9702324758,
"call_time": 4,
},
{
"Name": "Company15",
"Address": "2784 Stephanie Meadow, Kellyview, RI 41940",
"Phone": "(541)800-3165x84630",
"Email": "paynejacqueline@perkins.com",
"Website": "https://galvan-ho.com/",
"Year": 2015,
"Employees": 2934,
"Description": "Optional disintermediate installation",
"CEO": "Brianna Vang",
"TaxID": 9197588683,
"call_time": 3,
},
{
"Name": "Company16",
"Address": "USS Powers, FPO AE 79645",
"Phone": "799-737-6867",
"Email": "lhurst@ross.info",
"Website": "http://www.duke.org/",
"Year": 2005,
"Employees": 9444,
"Description": "Open-architected needs-based circuit",
"CEO": "Denise Robinson",
"TaxID": 5242686149,
"call_time": 9,
},
{
"Name": "Company17",
"Address": "21935 Roman Common Suite 870, New Erik, GU 39550",
"Phone": "399.755.1350x632",
"Email": "staceygordon@jones.com",
"Website": "https://www.williams.biz/",
"Year": 2000,
"Employees": 2496,
"Description": "Grass-roots tertiary matrix",
"CEO": "Amanda Matthews",
"TaxID": 3951572194,
"call_time": 3,
},
{
"Name": "Company18",
"Address": "5321 Sandra Flats Apt. 657, Port Timothy, IN 76963",
"Phone": "341-610-9720x396",
"Email": "christopher05@adams.com",
"Website": "https://www.coleman.com/",
"Year": 2015,
"Employees": 7697,
"Description": "Multi-tiered discrete projection",
"CEO": "Brenda Wilkerson",
"TaxID": 6565717553,
"call_time": 3,
},
{
"Name": "Company19",
"Address": "35623 Julie Walk, Hopkinsside, UT 67634",
"Phone": "+1-473-361-2745x37065",
"Email": "uwalker@stark.com",
"Website": "https://www.pena-walters.com/",
"Year": 1980,
"Employees": 4922,
"Description": "Synergized scalable encoding",
"CEO": "Stephanie Young",
"TaxID": 9620588390,
"call_time": 20,
},
{
"Name": "Company20",
"Address": "09618 Brooke Villages Apt. 178, East Spencerfurt, MA 26485",
"Phone": "(990)441-2290",
"Email": "xzimmerman@allen.com",
"Website": "https://www.burton.com/",
"Year": 1997,
"Employees": 2276,
"Description": "Enhanced 4thgeneration website",
"CEO": "David Valdez",
"TaxID": 9386061759,
"call_time": 7,
},
{
"Name": "Company21",
"Address": "813 Robert Way Apt. 941, South Paige, RI 03809",
"Phone": "001-292-812-7461x5232",
"Email": "cameronking@fleming.com",
"Website": "http://cooper.info/",
"Year": 1999,
"Employees": 5967,
"Description": "Fully-configurable eco-centric capacity",
"CEO": "Edward Allen",
"TaxID": 1198177347,
"call_time": 1,
},
{
"Name": "Company22",
"Address": "40332 Kathryn Green, South Taylor, TN 95398",
"Phone": "001-628-286-5262x2379",
"Email": "lperez@hall-jackson.biz",
"Website": "http://jones-perez.info/",
"Year": 2020,
"Employees": 2944,
"Description": "Face-to-face fresh-thinking model",
"CEO": "James Hansen",
"TaxID": 6392795545,
"call_time": 5,
},
{
"Name": "Company23",
"Address": "094 Kathleen Stream Apt. 125, Port Ashleyside, WV 84478",
"Phone": "480.427.2828",
"Email": "april40@payne.com",
"Website": "https://www.fitzpatrick-rasmussen.net/",
"Year": 1993,
"Employees": 518,
"Description": "Implemented analyzing knowledge user",
"CEO": "Mary Hill",
"TaxID": 5558335589,
"call_time": 5,
},
{
"Name": "Company24",
"Address": "80224 Roger Way, Michelletown, KS 84807",
"Phone": "755-817-3331x0542",
"Email": "nelsonfrank@bullock.com",
"Website": "http://www.moreno.net/",
"Year": 1989,
"Employees": 1768,
"Description": "Fully-configurable grid-enabled moderator",
"CEO": "Peter Spencer",
"TaxID": 8239869710,
"call_time": 1,
},
{
"Name": "Company25",
"Address": "24106 Robinson Walks, Gibsonhaven, TX 66568",
"Phone": "(947)767-2860x856",
"Email": "ericpratt@parker.info",
"Website": "https://rubio-webb.com/",
"Year": 2015,
"Employees": 6385,
"Description": "Reduced foreground workforce",
"CEO": "Erin Lowe",
"TaxID": 3626826838,
"call_time": 11,
},
]
async def call_company(task_info: Dict):
wait_time: int = task_info.get("call_time")
try:
if wait_time > 5:
return
await asyncio.sleep(wait_time)
print(
f"Company {task_info.get('Name')}: {task_info.get('Phone')} дозвон успешен"
)
except asyncio.CancelledError:
pass
async def main():
tasks = [
asyncio.create_task(call_company(task_info=phone_entry)) for phone_entry in data
]
_, pending = await asyncio.wait(tasks, timeout=10)
for pending_task in pending:
pending_task.cancel()
asyncio.run(main())