def process_input(stream):
    # stream is <_io.TextIOWrapper name='<stdin>' mode='r' encoding='UTF-8'>
    text = stream.readline()
    n = int(text.strip())
    print('[fileboj: {}]--> fib({}) = {}'.format(
        id(stream), n,
        timed_fib(n)))  # [fileboj: 140591049069912]--> fib(5) = 5
def read_input(loop):
    while True:
        line = yield sys.stdin
        if line == 'exit':
            loop.do_on_next_tick(loop.stop)
            continue
        n = int(line)
        print('fib({}) = {}'.format(n, timed_fib(n)))
def read_input(loop):
    while True:
        line = yield sys.stdin
        if line == 'exit':
            loop.do_on_next_tick(loop.stop)
            continue
        n = int(line)
        print('fib({}) = {}'.format(n, timed_fib(n)))
def on_stdin_input(line):
    if line == 'exit':
        loop.stop()
        return
    try:
        n = int(line)
        print("fib({}) = {}".format(n, timed_fib(n)))
    except ValueError:
        print(f"invalid literal for int() with '{line}'")
Ejemplo n.º 5
0
def read_input(loop):
    """
    Coroutine task to repeatedly read new lines of input from stdin, treat
    the input as a number n, and calculate and display fib(n).
    """
    while True:
        line = yield sys.stdin
        if line == 'exit':
            loop.do_on_next_tick(loop.stop)
            continue
        n = int(line)
        print("fib({}) = {}".format(n, timed_fib(n)))
Ejemplo n.º 6
0
def read_and_process_input():
    while True:
        n = int(input())  # 이때 gil blocking 풀림
        print('fib({}) = {}'.format(n, timed_fib(n)))
Ejemplo n.º 7
0
def read_and_process_input():
    while True:
        n = int(input("Input:"))
        print('fib({}) = {}'.format(n, timed_fib(n)))
Ejemplo n.º 8
0
def process_input(stream):
    text = stream.readline()
    n = int(text.strip())
    print('fib({}) = {}'.format(n, timed_fib(n)))
Ejemplo n.º 9
0
def read_and_process_input():
    while True:
        n = int(input())
        print('fib({}) = {}'.format(n,timed_fib(n)))
 def on_stdin_input(line):
     if line == 'exit':
         loop.stop()
         return
     n = int(line)
     print("fib({}) = {}".format(n, timed_fib(n)))