Skip to content

storeFile raise SMBTimeout exception on files > 1k #218

@dmlos

Description

@dmlos

Our code started to fail with SMBTimeout:

  File "/upload_to_fileshare.py", line 62, in copy_file_from_s3_to_network_share
    self.connection.storeFile(fs_share_name, destination_folder, source_data_fp)
  File "/usr/local/airflow/.local/lib/python3.10/site-packages/smb/SMBConnection.py", line 376, in storeFile
    return self.storeFileFromOffset(service_name, path, file_obj, 0, True, timeout, show_progress = show_progress, tqdm_kwargs = tqdm_kwargs)
  File "/usr/local/airflow/.local/lib/python3.10/site-packages/smb/SMBConnection.py", line 408, in storeFileFromOffset
    self._pollForNetBIOSPacket(timeout)
  File "/usr/local/airflow/.local/lib/python3.10/site-packages/smb/SMBConnection.py", line 607, in _pollForNetBIOSPacket
    raise SMBTimeout
smb.base.SMBTimeout

After investigation appeared that it able to store 1k of byte data, hence the workaround was:

offset = 0
while offset < source_data_fp.getbuffer().nbytes:
    offset = self.connection.storeFileFromOffset(
        service_name=fs_share_name,
        path=destination_folder,
        file_obj=io.BytesIO(source_data_fp.read(1024)),
        offset=offset,
        truncate=True if offset == 0 else False,
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions