# Buggy code
async def jsonrpc_file_reflect(self, **kwargs):
    """
    Reflect all the blobs in a file matching the filter criteria

    Usage:
        file_reflect [--sd_hash=<sd_hash>] [--file_name=<file_name>]
                     [--stream_hash=<stream_hash>] [--rowid=<rowid>]
                     [--reflector=<reflector>]

    Options:
        --sd_hash=<sd_hash>          : (str) get file with matching sd hash
        --file_name=<file_name>      : (str) get file with matching file name in the
                                       downloads folder
        --stream_hash=<stream_hash>  : (str) get file with matching stream hash
        --rowid=<rowid>              : (int) get file with matching row id
        --reflector=<reflector>      : (str) reflector server, ip address or url
                                       by default choose a server from the config

    Returns:
        (list) list of blobs reflected
    """

    server, port = kwargs.get("server"), kwargs.get("port")
    if server and port:
        port = int(port)
    else:
        server, port = random.choice(self.conf.reflector_servers)
    reflected = await asyncio.gather(
        *[
            stream.upload_to_reflector(server, port)
            for stream in self.stream_manager.get_filtered_streams(**kwargs)
        ]
    )
    total = []
    for reflected_for_stream in reflected:
        total.extend(reflected_for_stream)
    return total


# Traceback (AttributeError)
2019-08-01 18:18:06,916 INFO     lbry.stream.reflector.client:119: Sent reflector blob e5828b7e
2019-08-01 18:18:29,221 INFO     lbry.stream.reflector.client:119: Sent reflector blob 867d1a2c
2019-08-01 18:18:51,545 INFO     lbry.stream.reflector.client:119: Sent reflector blob 6e365367
2019-08-01 18:18:58,400 INFO     lbry.extras.daemon.Daemon:2330: publishing: name: xxxx params: {'title': 'xxxx', 'description': 'xxxxxx', 'bid': '0.10000000', 'languages': ['en'], 'tags': ['xxxxx'], 'thumbnail_url': 'https://spee.ch/8/xxxxxxxxx', 'license': 'All rights reserved   Published With Permission', 'release_time': 1564696220, 'channel_id': 'xxxxxxxxxxxx', 'fee_currency': 'LBC', 'fee_amount': '1.00000000', 'file_path': 'C:\\Users\\David T\\Desktop\\GMCZ0549_VID_1280x720x1500kbs_HCVC549.mp4'}
2019-08-01 18:19:22,348 ERROR    lbry.extras.daemon.Daemon:586: error handling api request
Traceback (most recent call last):
File "lbry\extras\daemon\Daemon.py", line 580, in _process_rpc_call
File "lbry\extras\daemon\Daemon.py", line 2342, in jsonrpc_publish
File "lbry\extras\daemon\Daemon.py", line 2659, in jsonrpc_stream_update
File "lbry\stream\stream_manager.py", line 232, in delete_stream
AttributeError: 'NoneType' object has no attribute 'stop_tasks'
2019-08-01 18:19:37,886 INFO     lbry.stream.reflector.client:119: Sent reflector blob f5b10e7b
2019-08-01 18:20:00,717 INFO     lbry.stream.reflector.client:119: Sent reflector blob d5ffe375

# Fixed code
async def jsonrpc_file_reflect(self, **kwargs):
    """
    Reflect all the blobs in a file matching the filter criteria

    Usage:
        file_reflect [--sd_hash=<sd_hash>] [--file_name=<file_name>]
                     [--stream_hash=<stream_hash>] [--rowid=<rowid>]
                     [--reflector=<reflector>]

    Options:
        --sd_hash=<sd_hash>          : (str) get file with matching sd hash
        --file_name=<file_name>      : (str) get file with matching file name in the
                                       downloads folder
        --stream_hash=<stream_hash>  : (str) get file with matching stream hash
        --rowid=<rowid>              : (int) get file with matching row id
        --reflector=<reflector>      : (str) reflector server, ip address or url
                                       by default choose a server from the config

    Returns:
        (list) list of blobs reflected
    """

    server, port = kwargs.get("server"), kwargs.get("port")
    if server and port:
        port = int(port)
    else:
        server, port = random.choice(self.conf.reflector_servers)
    reflected = await asyncio.gather(
        *[
            self.stream_manager.reflect_stream(stream, server, port)
            for stream in self.stream_manager.get_filtered_streams(**kwargs)
        ]
    )
    total = []
    for reflected_for_stream in reflected:
        total.extend(reflected_for_stream)
    return total