You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Gergely Kalmár (Jira)" <ji...@apache.org> on 2022/05/01 18:29:00 UTC

[jira] [Commented] (SPARK-38659) PySpark ResourceWarning: unclosed socket

    [ https://issues.apache.org/jira/browse/SPARK-38659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17530554#comment-17530554 ] 

Gergely Kalmár commented on SPARK-38659:
----------------------------------------

Yes, our test suite is failing because of these warnings. Also, keeping sockets open unnecessarily can be problematic for long-running services – this is sort of like a memory leak, not fatal in small amounts but it's better to not have it. Lastly, I would have expected that creating a spark session in a context manager cleans up everything when the context manager exits.

> PySpark ResourceWarning: unclosed socket
> ----------------------------------------
>
>                 Key: SPARK-38659
>                 URL: https://issues.apache.org/jira/browse/SPARK-38659
>             Project: Spark
>          Issue Type: Bug
>          Components: PySpark
>    Affects Versions: 3.2.1
>            Reporter: Gergely Kalmar
>            Priority: Minor
>
> Create a file called `spark.py` with the following contents:
> ```
> from pyspark.sql import SparkSession
> with SparkSession.builder.getOrCreate() as spark:
>     spark.read.csv('test.csv').collect()
> ```
> You can also create a `test.csv` file with whatever data in it. When executing `python -Wall spark.py` I get the following warning:
> ```
> /usr/lib/python3.8/socket.py:740: ResourceWarning: unclosed <socket.socket fd=7, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 51344), raddr=('127.0.0.1', 39221)>
>   self._sock = None
> ResourceWarning: Enable tracemalloc to get the object allocation traceback
> ```



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org