Code Monkey home page Code Monkey logo

libgfapi-python's Introduction

libgfapi-python

This is the official python bindings for the GlusterFS libgfapi C library interface.

Complete API reference and documentation can be found at ReadTheDocs.

Please follow the Developer Guide to contribute code.

libgfapi-python's People

Contributors

alphadelta14 avatar hansmi avatar humblec avatar osyvokon avatar prashanthpai avatar zandrr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libgfapi-python's Issues

Memory leak when mounting volumes?

Is there a memory leak in the API? Running the script below from the python interpreter results in a very high memory usage that stays high until exiting the python interpreter.

#foo.py

from gluster.gfapi import Volume

def main():
    for _ in xrange(20):
        v = Volume("master", "glustervolume")
        v.mount()
        v.umount()

if __name__ == "__main__":
    main()

This can also be seen using the vprof memory profiler

$ vprof -c cmh -s bar.py

Or am I missing something?

mount failed where used in Docker container

hi,
when i used gfapi in docker container,it raise a os.strerror excepiton.
here is the code and error message:

volume=gfapi.Volume('192.168.6.151','aifs')
volume.mount()
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/python3.6/lib/python3.6/site-packages/gluster/gfapi/gfapi.py", line 772, in mount
(self.fs, os.strerror(err)))
gluster.gfapi.exceptions.LibgfapiException: glfs_init(31859440) failed: Invalid argument
can anyone help me?

High memory consumption depending on volume bricks count

We've obtained very high memory usage produced by gfapi.Volume when mounted to big volume (with large bricks count). There are few experiment results, showing memory used by python process mounted to different envs:
Before mount (VSZ / RSS): 212376 / 8932
(2 nodes) 12 bricks volume : 631644 / 21440
(6 nodes) 384 bricks: 861648 / 276516
(10 nodes) 600 bricks: 987116 / 432028

Almost half GB per process just on start! And even more when actively used. As we are planning to run near 100 client nodes with 50 processes per node, amount of memory needed becomes fantastic.
Is there any reason for gfapi to use so much memory to just mount the volume?
Does that mean that server-side scaling up requires corresponding scaling up of client side?

Severe memory leak ?

Hello,

It seems these bindings are leaking a lot of memory. Walking through a two level tree with 87 000 files adds a never freed 60 Mbytes memory used to my application. It's getting worst then while running fopen (I'd say around 3Mbytes per 100 fopen).

Is that known ?

Regards, Adam.

Calling `fopen` from python thread

The following test (specifically, test_single_thread) segfaults, though, presumably, it should not:

import unittest
import threading
import os

from gluster import gfapi


class GlusterCrashesTestCase(unittest.TestCase):

    def test_normal_connection(self):
        v = gfapi.Volume('glusterserver', 'gv', log_file='/tmp/gluster.log')
        v.mount()
        assert v.mounted
        assert isinstance(v.listdir('/'), list)  # <- this and many other functions work fine

        with v.fopen('test.tmp', 'w') as f:      # <- this will segfault in threaded environment
            f.write(b'test')

        v.umount()
        assert not v.mounted

    def test_single_thread(self):
        # Causes segfault
        thread = threading.Thread(target=self.test_normal_connection)
        thread.start()
        thread.join()


if __name__ == '__main__':
    unittest.main()

Is it possible to use libgfapi-python with threads?

ctype error

In [1]: from gluster import api

AttributeError Traceback (most recent call last)
in ()
----> 1 from gluster import api

/usr/lib/python2.6/site-packages/gfapi-0.0.1-py2.6.egg/gluster/api.py in ()
321 ctypes.c_int)(('glfs_lseek', client))
322
--> 323 glfs_read = ctypes.CFUNCTYPE(ctypes.c_ssize_t,
324 ctypes.c_void_p,
325 ctypes.c_void_p,

AttributeError: 'module' object has no attribute 'c_ssize_t'

OS: centos 6.5
python: 2.6.6

Compatible GlusterFS versions?

Which version(s) of GlusterFS should this work with this?

Trying out GlusterFS 3.5 development head on EL6 today gives this:

$ python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gluster import gfapi
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/gfapi-0.0.1-py2.6.egg/gluster/gfapi.py", line 54, in <module>
    api.glfs_creat.restype = ctypes.c_void_p
  File "/usr/lib64/python2.6/ctypes/__init__.py", line 366, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib64/python2.6/ctypes/__init__.py", line 371, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: python: undefined symbol: glfs_creat
>>> 
$ rpm -qa|grep -i gluster|sort
glusterfs-3git-1.el6.x86_64
glusterfs-cli-3git-1.el6.x86_64
glusterfs-debuginfo-3git-1.el6.x86_64
glusterfs-devel-3git-1.el6.x86_64
glusterfs-fuse-3git-1.el6.x86_64
glusterfs-geo-replication-3git-1.el6.x86_64
glusterfs-libs-3git-1.el6.x86_64
glusterfs-rdma-3git-1.el6.x86_64
glusterfs-regression-tests-3git-1.el6.x86_64
glusterfs-server-3git-1.el6.x86_64
$

Missing type error for Python 3?

In python 3.6.2 when writing a string to a file directly like this:
volume = gfapi.Volume('server', 'volume') volume.mount() with volume.fopen('testfile', 'w') as f: f.write("test write")

The resulting file gets weirdly cut like this:
xxd testfile 00000000: 7400 0000 6500 0000 7300 00 t...e...s..

This works:
with volume.fopen('testfile', 'w') as f: f.write(b'test write') xxd testfile 00000000: 7465 7374 2077 7269 7465 test write

Maybe the write function should throw a type error in Python 3 if the object is not a bytearray/byte?

Using the API without running as root

How can I use the API without running as root?

Using the example here in a file called foo.py I get the following results

$ python foo.py
Traceback (most recent call last):
  File "foo.py", line 5, in <module>
    volume.mount()
  File "/usr/local/lib/python2.7/dist-packages/gfapi-0.0.1-py2.7.egg/gluster/gfapi.py", line 563, in mount
    (self.fs, os.strerror(err)))
gluster.exceptions.LibgfapiException: glfs_init(42493440) failed: Transport endpoint is not connected

$ sudo python foo.py
Winter is coming.

read a file from volume

reading any multimedia file from volume only reads a part of file.
fget size give complete size of file but read only reads part of it.
tried on .png and mp3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.